AlertDialog点击自动关闭对话框

pwdDialog = new AlertDialog.Builder(this)
		.setTitle("密码修改")
		.setIcon(null)
		.setView(content)
		.setPositiveButton("提交",new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface xdialog, int which) {
				//设置不关闭对对话框
        		try { 
        			Field field = xdialog.getClass().getSuperclass().getDeclaredField("mShowing"); 
        			field.setAccessible(true); 
        			field.set(xdialog, false);
    			} catch (Exception e) { 
        			e.printStackTrace(); 
        		}
        		String oldpwd = oldTx.getText().toString();
        		String newpwd = newTx.getText().toString();
        		String confpwd = confTx.getText().toString();
        		if(StringUtil.isBlank(oldpwd)){
        			Toast.makeText(SysManager.this,"请填写原密码!", Toast.LENGTH_SHORT).show();
        			return;
        		}
        		if(StringUtil.isBlank(newpwd)){
        			Toast.makeText(SysManager.this,"请填写新密码!", Toast.LENGTH_SHORT).show();
        			return;
        		}
        		if(StringUtil.isBlank(confpwd)){
        			Toast.makeText(SysManager.this,"请确认新密码!", Toast.LENGTH_SHORT).show();
        			return;
        		}
        		if(!newpwd.equals(confpwd)){
        			Toast.makeText(SysManager.this,"两次密码不一致!", Toast.LENGTH_SHORT).show();
        			return;
        		}
        		postChangePwd(oldpwd, newpwd);
        		//关闭对话框
        		try {
    				Field field = xdialog.getClass().getSuperclass().getDeclaredField("mShowing");
    				field.setAccessible(true);
    				field.set(xdialog, true);
				} catch (Exception e) {
    				e.printStackTrace();
    			}
			}
		})
		.setNegativeButton("取消",new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface xdialog, int which) {
			}
		}).create();



你可能感兴趣的:(AlertDialog点击自动关闭对话框)