Package com. demo;
Import android. app. Dialog;
Import android. content. Context;
Import android. OS. Bundle;
Import android. view. View;
Import android. view. View. OnClickListener;
Import android. widget. Button;
Public class LeaveMeetingDialog extends Dialog implements OnClickListener {
Private Button quitBtn, stopBtn, cancelBtn;
Private LeaveMeetingDialogListener listener;
Public interface LeaveMeetingDialogListener {
Public void onClick (View view );
}
Public LeaveMeetingDialog (Context context, int theme, LeaveMeetingDialogListener listener ){
Super (context, theme );
}
@ Override
Protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. leave_meeting_dialog );
InitViews ();
}
Private void initViews (){
QuitBtn = (Button) findViewById (R. id. quit_btn );
StopBtn = (Button) findViewById (R. id. stop_btn );
CancelBtn = (Button) findViewById (R. id. cancel_btn );
QuitBtn. setOnClickListener (this );
StopBtn. setOnClickListener (this );
CancelBtn. setOnClickListener (this );
}
@ Override
Public void onClick (View v ){
Listener. onClick (v );
}
}
--- Call:
[Java]
LeaveMeetingDialog dialog = new LeaveMeetingDialog (this, R. style. Theme_CustomDialog,
New LeaveMeetingDialogListener (){
@ Override
Public void onClick (View view ){
Switch (view. getId ()){
Case R. id. quit_btn: break;
Case R. id. stop_btn: break;
Case R. id. cancel_btn: break;
}
}
});
Dialog. show ();
From liuxiIT's column