How can I reference TextView by using its id in a String variable, like:
xml file:
<TextView
android:id="@+id/hello1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
/>
<TextView
android:id="@+id/hello2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
/>
code:
public void changetext(String z){
String x ="R.id.hello"+z;
TextView y = (TextView) findViewById(x);
y.setText("I've changed");
}