tags:

views:

42

answers:

1

I used the layout resource editor to modify the main.xml layout file to add a second TextView control to my app. by default, its set to something like @+id/TextView01. How do I Set the text attribute of the TextView control to my newly created String resource? I tried going into main.xml and just editing the android:text to point to the name of my new string, but it didn't seem to work.

A: 

you define your strings inside resources/strings/values.xml and you can reference them using "@string/name_of_string" syntax in your layouts.

android:text="@string/name_of_string"

madsleejensen
Thanks a lot for your help. That's what I tried doing. I added <string name="rules">Random text bla bla</string> to strings.xml and then added <TextView android:text="@string/rules" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> Did I make some basic mistake?
LuxuryMode
Got it, thanks!
LuxuryMode
just a note: don't forget to mark an answer as accepted if it solved your problem...
Sotapanna
@the sotapanna dont see your username on any answer
LuxuryMode
@LuxuryMode: it's about accepting the answer, not about seeing a name somewhere. http://meta.stackoverflow.com/questions/5234/how-does-accepting-an-answer-work Nevermind, I just wanted to point out...
Sotapanna
@LuxuryMode, theres a arrow on my answer you can click, to accept the answer i given.
madsleejensen
I knew how to accept an answer, but you confused me by signing in and commenting as two, separate users. :-)
LuxuryMode
Im not "The Sotapanna" if thats what your thinking :)
madsleejensen