对于自定义AlertDialog,我能否覆盖正面按钮以不关闭对话框?相反,如果我的检查失败,我想要运行一些编辑检查并保持对话框打开。
protected Dialog onCreateDialog(int id) {
Dialog alertDialog = null;
builder = new AlertDialog.Builder(this);
switch(id) {
case LOGIN_USERID_BLANK:
builder.setMessage((String)getString(R.string.username_not_blank));
builder.setPositiveButton((String)getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Can I do something here so that the dialog does not close?
}
});
中断执行;