Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法DialogPreference在任何事件中获得 a 的积极按钮?
DialogPreference
我想最初禁用它,并在EditText验证后启用它。
EditText
只需调用
(AlertDialog)dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
但是,如果您使用的是 Dialog Builder,请确保在builder.create()之前和之前调用它.show()
builder.create()
.show()
然后,您可以保留对对话框的引用并在满足条件后启用按钮。