Class-1
public class MyHeader {
private Button button1,button2;
public MyHeader(Activity source) {
this.button1 = (Button)source.findViewById(R.id.b_one);
this.button2 = (Button)source.findViewById(R.id.b_two);
// ...
}
public Button getHeaderButtonOne() { return button1; }
// And so on...
class-2
private MyHeader header;
// ... in onCreate() method
header = new MyHeader(this);
Using this code, in class 2 I am able to access the button for which I got the id in class1. Now I want to get the onclick event for the button set in class 1 and if i get the button in class 2 I should be able to use the click event also.
Just add a new method in your class-1:
and call it from your class-2 like this: