I have one common layout that has four button at top bar and i am using this layout in all activities by including that common layout in all activities layout by
Create a static object in order to listen to the button clicks.Based on this object handle events in all activities.
For example say Constants.class:
public class Constants {
private static int buttonState1;
public static int getButtonState(){
return buttonState1;
}
public static int setButtonState(int x){
buttonState1=x;
}
}
And in your activity:
Button bt1=(Button) findViewById(R.id.bt1);
bt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Constants.setButtonState(1);
}
});
And in other activities
if(Constants.getButtonState()==1)
//do something