Answer the question
In order to leave comments, you need to log in
How to implement text change when switching to another activity?
There is:
an activity with two buttons (btn_1; btn_2) and a second activity with a TextView.
String resource
<string name="tx_1">Hello</string>
<string name="tx_2">Android</string>
Answer the question
In order to leave comments, you need to log in
@Override
public void onClick(View view) {
Intent intent = new Intent(this, SecondActivity.class);
switch(view.getId()){
case(R.id.btn1):
intent.putExtra(EXTRA_MESSAGE, getResources().getString(R.string.tx_1));
startActivity(intent);
break;
case(R.id.btn2):
intent.putExtra(EXTRA_MESSAGE, getResources().getString(R.string.tx_2));
startActivity(intent);
break;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question