I got a simple script:
int phases = 6;
final int max = 8;
final TextView[] a = new TextView[(max * phases)];
final Button[] b = new Button[phases]; // creates the buttons to display
// the single phases
for (int x = 0; x < phases; x++) {
b[x] = new Button(this);
b[x].setText("yourbutton");
// linL.addView(b[x]);
b[x].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (a[(3)].getVisibility() == 0) {
for (int i = 0; i < max; i++)
a[i].setVisibility(View.GONE);
} else {
for (int i = 0; i < max; i++)
a[i].setVisibility(View.VISIBLE);
}
};
});
}
This checks basically if a textview is visible and if it's not then it makes it visible (plus the other way round).
My problem is now that I don't want to switch the same text views on again and again, I want to change the views depending on the x of the current loop of the button creation.
However, when i try to include this x, it says that it has to be final.
So how do i get parameters into that on click listener script? (I tried to add them, however it said then that I have to program the whole listener again...that's why I'm asking if there's a smarter way to do it)
Cheers, Christoph