Android: ¿Cómo cambio un valor que está definido en el xml dentro del código java?
Frecuentes
Visto 59 veces
0
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?
1 Respuestas
0
Question kind of vague but anyway here is my answer
<resources>
<integer-array name="UserBases">
<item>2</item>
<item>8</item>
<item>10</item>
<item>16</item>
</integer-array>
</resources>
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 https://www.youtube.com/watch?v=xB-eutXNUMXJtA&feature=youtu.be - Erik
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas android or haz tu propia pregunta.
You can access xml values using getResources(). check the resources class documentation on the respective API's. In your case, it might be getInteger(). - prijupaul
I usegetView().findViewById(R.dimen.text_size), but then how do I change that? - Faraz Masroor
You should be using getResources().getDimension(R.dimen.text_size) to get the value set. findViewById will only find the Views and not dimentions. - prijupaul