I'm writing an android app and I'm trying to initialize a grid of buttons in with a nested loop.
i originally found this current solution through research but i cant figure out whats going wrong.
for (int i = 0; i < piles.length; i++)
for (int j = 0; j < piles[0].length; j++) {
id = getResources().getIdentifier("R.id." + "b" + numplayaz + Integer.toString(i) + Integer.toString(j), "id","app.dj");
bpiles[i][j] = ((Button) this.findViewById(id));
bpiles[i][j].setOnClickListener(this);
}
}
for some reason when id is always set to 0 and thus bpiles[0][0] is set to null, and then get a null pointer exception.
i'v tried allot of little solutions but nothing has worked.
does anyone either see what my problem is or have a better solution to this.
oh, and i came up with this when i saw this post. Android findViewbyId with a variant string