here's a suggestion based on your explanation. Please remember that I'm typing it all by hearts and it's likely to have a few typos.
STEP 1: in my main activity (class A), i call a method (in class B) that creates dinamically several buttons.
public class A extends Activity implements OnClickListener{
private ArrayList<Buttons> mybuttons = new ArrayList<Butons>
// ... at some point you call B
mybuttons.addAll(b.createButton(this));
// createButtons should receive an OnClickListener as parameter to set on the buttons
// createButtons returns a List<Buttons> that you add to your list.
// note that it's NOT a static list, and that the list is part of the Activity, the Activity can hold reference to its views without problem
}
STEP 2: When users click one of these buttons i call a method (in class C) that check if users "did somethings".
STEP 3: If users did somethings, from Class C i call a method (in class D) that disables all the buttons i created in class B.
// because A implements the OnClickListener, the OnClick is called inside A
onClick(View v){
// call the C to check. and make it return a boolean (true or false)
if(c.CheckStuff()){
// disable your buttons.
for(Button btn:mybuttons) { btn.setEnabled(false); }
}
}
Question: What's the right way to reach, from class D, the buttons created in class B
answer: you don't have to, to be fair, if D is only disabling the buttons is only that ONE line I typed. If it's doing more stuff, you can pass mybuttons
to D, but I urge to not keep a permanent reference of it inside D, that's because D is not part of the activity life-cycle.