Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically reference <string> in xml file in android [closed]

I am new to android programming and wanna know this:

I have 3 strings defined in the strings.xml file: <resources> <string name="one">First Click </string> <string name="two">Second Click </string> <string name="three">Third Click </string> <resources>

and a text view which displays the first string in the strings.xml file. i don't want to use settext("******") to change the text of text view when the user clicks on a button. how can i make the textview switch to the text already defined in the strings.xml file, say from

First Click to Second Click

like image 640
thunderson Avatar asked Nov 12 '12 05:11

thunderson


1 Answers

Use setText(getResources().getString(R.string.one));

like image 140
Android Boy Avatar answered Oct 28 '22 00:10

Android Boy