dimanche 28 octobre 2018

how to change Textview text with button

I have one textview and one button ,i coud change textview text with below code :

final Textview c_tv_matn;
Button c_btn_dokme;


c_btn_dokme = (button) findviewbyid(R.id.btn1);
c_tv_matn = (Textview) findviewbyid(R.id.txt1);

c_btn_dokme.setonclickListener(new OnclickListener() {
@Override
public void onClick(View v) {
c_tv_matn.SetText("this is second text");
});

But i wanna change text from String.xml and make Next Button Like this ; "matn_1","matn_2"matn_3"matn_4...

STRING.XML

<string name="matn_0">Hello world!</string>
 <string name="matn_1">You are hero john</string>
<string name="matn_2">you can change this world</string>
<string name="matn_3">You are so clever</string>

cAN YOU HELP ME TO GET RES FROM STRING AND CHANG TEXTVIEW TEXT WITH NUMBERS?




Aucun commentaire:

Enregistrer un commentaire