I'm new to Android and I'm trying to make a 9x9 table that is full of TextViews in each cell. And I want to put numbers from an array with a setText () in each TextView.
The problem is that I do not know how to make the TextView id automatic.
I have the following:
int z = 0;
int contador = 0;
for(int y = 1; y <= 9; y++) { //Filas
for (int x = 1; x <= 9; x++) { //Columnas
String nombreCF = "c"+x+"f"+y; //Id de los text view c1f1, c2f1, c3f1...
contador = 0;
for(z=z; contador < 1; z++){
nombreCF.setText(items[z]); //ERROR nombreCF no se le puede poner un setText()
contador=1;
}
}
}
As you can see I tried to make the textview id a string with the number of row and column generated by a loop but of course a string does not have the function setText ().
I do not know if I'm making a mess but you know how to help me do it?
Thank you very much!
I forgot to put the array I want it to have. There must be a number by TextView.
static int [] items = {7,9,2,6,1,5,3,8,4,5,8,3,7,4,2,6,9,1,1,6, 4,3,9,8,5,2,7,9,4,8,2,6,3,7,1,5,2,7,5,4,8,1,9,6,3, 6,3,1,9,5,7,2,4,8,8,5,7,1,2,9,4,3,6,3,2,6,6,7,4,1, 5,9,4,1,9,5,3,6,8,7,2};