Android alertdialog的按钮点击后不消失
2011-12-23 11:18
316 查看
使用反射:
在你的setPositiveButton中添加:
//用于不关闭对话框
try {
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
field.set(dialog, false);
} catch (Exception e) {
e.printStackTrace();
}
添加上述代码后就可以使dialog无法关闭,在你需要关闭的地方,添加:
//关闭对话框
try {
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
field.set(dialog, true);
} catch (Exception e) {
e.printStackTrace();
}
在你的setPositiveButton中添加:
//用于不关闭对话框
try {
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
field.set(dialog, false);
[align=center][/align] |
e.printStackTrace();
}
添加上述代码后就可以使dialog无法关闭,在你需要关闭的地方,添加:
//关闭对话框
try {
Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
field.set(dialog, true);
} catch (Exception e) {
e.printStackTrace();
}
相关文章推荐
- android开发之AlertDialog点击按钮之后不消失
- android alertdialog的按钮点击后不消失
- android开发之AlertDialog点击按钮之后不消失
- android点击AlertDialog上的按钮后让其不消失
- Android 点击AlertDialog上的确定和取消按钮,使对话框不消失
- Android AlertDialog解决点击按钮立即消失的问题
- android开发之AlertDialog点击按钮之后不消失 分类: android 学习笔记 2015-07-15 18:07 89人阅读 评论(0) 收藏
- Android alertdialog的按钮点击后不消失
- android开发之AlertDialog点击按钮之后不消失
- android之AlertDialog 点击其他区域自动消失
- Android使alertDialog.builder不会点击外面和按返回键消失的方法
- android之AlertDialog 点击其他区域自动消失
- AlertDialog点击按钮后对话框不消失的处理方法
- android之AlertDialog 点击其它区域自己主动消失
- android之AlertDialog 点击其他区域自动消失
- 使android dialog点击按钮dialog不消失的方法
- Android实现点击AlertDialog上按钮时不关闭对话框的方法
- Android Alert Dialog解决点击按钮对话框不关闭/的问题
- android点击按钮 使alertDialong 对话框 不消失
- Android 自定义的Dialog,点击确定按钮,让其根据条件判断消失与否