美文网首页Android 成长笔记
Android 设置对话框中的确定按钮的 enabled 属性

Android 设置对话框中的确定按钮的 enabled 属性

作者: 赵者也 | 来源:发表于2018-03-20 19:59 被阅读5次

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);

相关文章

网友评论

    本文标题:Android 设置对话框中的确定按钮的 enabled 属性

    本文链接:https://www.haomeiwen.com/subject/ixfiqftx.html