简体   繁体   中英

Setting TextView to new string?

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.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM