0
私のコードのNegativeButtonを設定します方法として以下のAlertDialog.Builder unclickable
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Dialog");
dialog.setPositiveButton("Check", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
if(condition) {
//set NegativeButton unclickable
} else {
//set NegativeButton clickable
}
} // end of onClick
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
//do something
}
});
はどのようNegativeButtonをクリックしてunclickable設定しますか? onclickの状態をチェックするためのコードの下
... ...
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
if(condition) {
//set NegativeButton unclickable
alertDialog.getButton(Dialog.BUTTON_NEGATIVE).setClickable(false);
} else {
//set NegativeButton clickable
alertDialog.getButton(Dialog.BUTTON_NEGATIVE).setClickable(true);
}
NULLポインタエラー – brian
@brian、おそらくalert alertDialog.show()コールが必要です。まず、私の答えを更新しました。 – yorkw