AlertDialogのキャンセルや閉じるイベントのハンドリングは、Dialogクラスのリスナー設定メソッドを使用します。
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
public class MyClass extends Activity{
public void myMethod(){
AlertDialog.Builder bldr = new AlertDialog.Builder(this);
AlertDialog dialog = bldr.create();
// キャンセル
dialog.setOnCancelListener(new DialogInterface.OnCancelListener(){
public void onCancel(DialogInterface dialog){
}
});
// 閉じる
dialog.setOnDismissListener(new DialogInterface.OnDismissListener(){
public void onDismiss(DialogInterface dialog){
}
});
bldr.show();
}
}
参考: ダイアログのボタンイベント
参考: ダイアログのカスタマイズ


コメント