contentview가 사용자 정의 뷰 그룹 인 사용자 정의 대화 상자 (대화 상자 확장)가 있습니다. 뷰 그룹에는 몇 개의 edittext 자식이 있지만 뷰 그룹의 dispatchDraw 및 onTouch 메서드에서 직접 드로잉 및 단추를 클릭 할 것입니다 (가능한 많은 뷰를 부 풀리지 않으려 고합니다). 구체적으로이보기에는 대화 상자의 닫기 버튼으로 설정할 수있는 버튼 자식이 없습니다.보기 그룹의 onTouch 메서드 내에서 대화 상자 을 닫으려고하지만 뒤로 키를 눌러 시뮬레이션하는 것 이상으로이 작업을 수행하는 방법을 알 수 없습니다.비 xml 콘텐츠 뷰에서 대화 닫기 Discomiss
활동 코드 :
public class My_Activity extends Activity {
...
public void onCreate(Bundle savedInstanceState) {
...
//if there's no Class_That_Im_Editing in the database, prompt the user to make a new one by adding information to the editviews in this custom dialog and clicking the area where I draw the ok button
my_dialog = new Custom_Dialog(this, R.style.CustomDlg, new Class_That_Im_Editing());
}
}
대화 코드 :
public class Custom_Dialog extends Dialog {
...
public void onCreate(Bundle savedInstanceState) {
...
setContentView(new Custom_ViewGroup(context, Class_That_Im_Editing));
}
}
뷰 그룹 코드 :
public class Custom_ViewGroup extends ViewGroup implements OnTouchListener {
//this class has some edittext children but _no_ buttons
...
public boolean onTouch(View view, MotionEvent event) {
if (logic checking if the user has clicked the button area) {
//??? what do I put here to dismiss the dialog
}
}
}
나는 dismissDialog (int) 메소드를 사용하고 생각할 수있는 유일한 방법 이는 onCreateDialog 및 onPrepareDialog 이벤트 처리기를 재정의 (override)하는 것을 의미합니다. 하지만 view의 onTouch 메서드 내에서 dismissDialog를 호출하려면 어떻게해야합니까?
어쩌면 나는 어떤 종류의 청취자를 설치해야합니까? 그렇다면이 작업을 수행하는 데 필요한 뼈대 코드는 무엇입니까?