Android 设置对话框中的确定按钮的 enabled 属性的方法如下:
final AlertDialog dialog = new AlertDialog.Builder(this)
.setMessage("some things")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO: 18-3-20
}
})
.setNegativeButton("取消", null)
.create();
dialog.show();
// the follow code must after the dialog.show();
dialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE).setEnabled(false);
网友评论