I have a TableLayout which has 3 TableRows and within the rows there are 3 ImageViews. What I am trying to do is iterate through the table and setImageResource for each ImageView in the table. I have tried using this code, but I am getting stuck with this problem. I am a beginner at Android, any help is greatly appreciated, thank you.
My code as follows...
TableLayout tableLayout = (TableLayout) findViewById(R.id.tableLayout);
TableRow tableRow = (TableRow)tableLayout.getChildAt(0);
ImageView imageView = (ImageView)tableRow.getChildAt(0);
int x = tableLayout.getChildCount();
for(int i = 0; i < x; i++){
tableRow= (TableRow)tableLayout.getChildAt(i);
for( int j = 0; j < 3; j++){
imageView = (ImageView)tableRow.getChildAt(j);
imageView.setImageResource(0);
}
}
My code as follows...
TableLayout tableLayout = (TableLayout) findViewById(R.id.tableLayout);
TableRow tableRow = (TableRow)tableLayout.getChildAt(0);
ImageView imageView = (ImageView)tableRow.getChildAt(0);
int x = tableLayout.getChildCount();
for(int i = 0; i < x; i++){
tableRow= (TableRow)tableLayout.getChildAt(i);
for( int j = 0; j < 3; j++){
imageView = (ImageView)tableRow.getChildAt(j);
imageView.setImageResource(0);
}
}