I wanted to find different TextViews
, which are depending on an integer.
Let's say I have got three TextViews:
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
And in my MainActivity I have got following:
String resourceText = "R.id.text";
int textCounter = 1;
TextView text1 = (TextView) findViewById(resourceText + textCounter);
So the result should be that I am able to access different TextViews over the textCounter but it doesn't work.
But using this code gives me an error which says that the findViewByID function expects an integer.