What I am trying to do is create N (in this case 9) copies of the ImageView object R.id.tile, place each of them at different coordinates on the layout
Edit:
First create a layout with one ImageView with the properties you like
Example:
create file in res/layout/singleimage.xml
And then inflate the ImageView to get the copies of it like this
View[] tiles = new ImageView[9];
// get reference to LayoutInflater
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
for(int i = 0; i
You have set id to i value here
tiles[i].setId(i);
But you are (incorrectly) trying to get it from your other resource (the one you wanted to 'clone'):
layout.addView(tiles[i] = (ImageView) findViewById(R.id.tile)); // INCORRECT
Instead, set the id manually as above, and then:
layout.addView(tiles[i]);
And there is no need to call findViewById()