AlertDialog 点击按钮后不关闭的处理办法
2016-05-19 22:33
411 查看
newAlertDialog.Builder(
this).setPositiveButton(
newString(
"
确定
"),
newDialogInterface.OnClickListener()
{ @Override
publicvoid
onClick( DialogInterface dialog,
intwhich )
{
if(
判断条件 )
{
//
条件不成立不能关闭 AlertDialog
窗口
try
{
Field field = dialog.getClass().getSuperclass().getDeclaredField(
"mShowing");
field.setAccessible(
true);
field.set( dialog,
false);
// false -
使之不能关闭
(
此为机关所在,其它语句相同
)
}
catch( Exception e )
{
Log.e( e.getMessage() );
e.printStackTrace();
}
}
else
{
//
条件成立能关闭 AlertDialog
窗口
try
{
Field field = dialog.getClass().getSuperclass().getDeclaredField(
"mShowing");
field.setAccessible(
true);
field.set( dialog,
true);
// true -
使之可以关闭
(
此为机关所在,其它语句相同
)
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
this).setPositiveButton(
newString(
"
确定
"),
newDialogInterface.OnClickListener()
{ @Override
publicvoid
onClick( DialogInterface dialog,
intwhich )
{
if(
判断条件 )
{
//
条件不成立不能关闭 AlertDialog
窗口
try
{
Field field = dialog.getClass().getSuperclass().getDeclaredField(
"mShowing");
field.setAccessible(
true);
field.set( dialog,
false);
// false -
使之不能关闭
(
此为机关所在,其它语句相同
)
}
catch( Exception e )
{
Log.e( e.getMessage() );
e.printStackTrace();
}
}
else
{
//
条件成立能关闭 AlertDialog
窗口
try
{
Field field = dialog.getClass().getSuperclass().getDeclaredField(
"mShowing");
field.setAccessible(
true);
field.set( dialog,
true);
// true -
使之可以关闭
(
此为机关所在,其它语句相同
)
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
相关文章推荐
- 【蓝桥杯】穿越雷区-java语言描述
- 国内从事机器视觉领域的公司
- SQLServer数据库文件由高版本向低版本转换
- Echarts xAxis boundaryGap
- aggregation 详解4(pipeline aggregations)
- Apache Atlas安装文档
- Java注解基础(一)
- liunx vim常用设置
- Codeforces--675C--Money Transfers(思维)
- 如何在ListView中的TextView显示跑马灯效果?
- servlet的执行原理与生命周期
- 剑指Offer----面试题五:从尾到头打印链表
- TCP/IP 协议大致的概念
- 2,理解JVM
- 我的缓存世界观
- Linux系统小知识汇总
- EasyDarwin开源流媒体服务器gettimeofday性能优化(3000万/秒次优化至8000万次/秒)
- JAVA设计模式(24):创建型-工厂模式【工厂方法模式】(Factory Method)
- EasyDarwin开源流媒体服务器gettimeofday性能优化(3000万/秒次优化至8000万次/秒)
- yousa_team团队项目——兼职平台网站 工作进度