New to android development, but not entirely new to Java. Right now my code inside the onCreate() method is quite basic:
Button b1 = (Button) findViewById(R.
in onCreate
call get the root layout
ViewGroup rootLayout=(ViewGroup) findViewById(R.id.root_layout);
then pass it to this method, (using recursive for deep search for buttons)
public void setAllButtonListener(ViewGroup viewGroup) {
View v;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
v = viewGroup.getChildAt(i);
if (v instanceof ViewGroup) {
setAllButtonListener((ViewGroup) v);
} else if (v instanceof Button) {
((Button) v).setOnClickListener(myButtonsListener);
}
}
}
good luck