In my Android Studio program I would like to put a variable in my Id. The code lines in here aren't all the code lines but they are the important code lines for this question.
I created an ids.xml file and put these id's in:
<resources>
<item type="id" name="layout0" />
<item type="id" name="layout1" />
<item type="id" name="layout2" />
<item type="id" name="layout3" />
 ...
<item type="id" name="layout49" />
</resources>
And now i want to set the id to my id to an image view with the Pointer variable. It needs to become R.id.layout0.
public boolean onTouchEvent(MotionEvent event) {
ImageView ImageView1;
int pointer;
switch (action)
    {
        case MotionEvent.ACTION_DOWN:
        {
            pointer=MotionEventCompat.getActionIndex(event);
            ImageView1.setId(Integer.parseInt("R.id.layout" + pointer));
            break;
        }
}
The searches I did and what the answer could be:
ImageView1.setId(Integer.parseInt("R.id.layout" + pointer));
Or with a IdRes:
IdRes id;
...
id= "R.id.layout" + Pointer;
But they both give errors because you cant Integer.parsInt with a String and the Id Res can't be a String either.
Any way to do this?