0
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...
클래스 2
private MyHeader header;
// ... in onCreate() method
header = new MyHeader(this);
이 코드를 사용하여, 나는 버튼에 액세스 할 수 있어요 클래스 2 내가 class1에있는 이드를 얻었습니다. 이제 클래스 1에 설정된 버튼에 대한 onclick 이벤트를 가져오고 클래스 2의 버튼을 얻으면 click 이벤트도 사용할 수 있어야합니다.