Android: ¿Cómo cambio un valor que está definido en el xml dentro del código java?

I have multiple tabs with text on them. I have another tab which is responsible for holding the GUI elements to change the value of the default text size. I already have a default value set in the xml files. How might I go about doing this, creating a variable that is accessible to all activities?

preguntado el 09 de septiembre de 13 a las 23:09

You can access xml values using getResources(). check the resources class documentation on the respective API's. In your case, it might be getInteger(). -

I usegetView().findViewById(R.dimen.text_size), but then how do I change that? -

You should be using getResources().getDimension(R.dimen.text_size) to get the value set. findViewById will only find the Views and not dimentions. -

1 Respuestas

Question kind of vague but anyway here is my answer

         <integer-array name="UserBases">

Resources r = getResources();
int[] bases = r.getIntArray(R.array.UserBases)

Use el bases array to pic your size

Here's the way to do it Comunicarse con otros fragmentos

Respondido el 09 de Septiembre de 13 a las 23:09

Yes but how do I make it consistent throughout? - Faraz Masroor

You have to let them all know what <item>xxx</item> to use. You could create an interface that will tell everyone what to do. What we are talking about now is standard communication among Activities and fragment. Check this - Erik

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.