android - Need help to change TextView -
i'm trying change text dynamically tictactoe game.
letexte = (textview) findviewbyid(r.id.text);
i want put on screen textview wich going change, example if player x won game, "player x won" displayed, or "joueur x gagne" in french.
it's easy me manually in 1 language using
letexte.settext("player x won");
but want use xml files many other languages. here sample of main xml
android:id="@+id/text" android:text="@string/text"
and english strings.xml looks this
<string name="text"></string> //nothing @ start <string name="textx">player x wins</string> <string name="texto">player o won !</string> <string name="textt">tie !</string> <string name="textu">your turn</string>
so, how can change text using "name" ?
you can refer strings in strings.xml below
tv.settext(r.string.text);
in code: using static integer sub-class of r class, such as:
r.string.text
string resource type , text resource name.
more details @ http://developer.android.com/guide/topics/resources/accessing-resources.html.
Comments
Post a Comment