AlertDialog 点击按钮后不关闭的处理办法
发布日期:2021-06-30 18:38:55
浏览次数:2
分类:技术文章
本文共 1347 字,大约阅读时间需要 4 分钟。
AlertDialog 点击按钮后不关闭的处理办法
new AlertDialog.Builder( this ).setPositiveButton( new String( "确定" ), new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog, int which ) { 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(); } } } }
转载地址:https://linqiarui.blog.csdn.net/article/details/51049199 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月12日 11时59分44秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
CodeForces - 996D Suit and Tie (暴力)
2019-04-30
ACM 2017 香港区域赛 E - Base Station Sites(二分)
2019-04-30
ACM 2018 青岛区域赛 J-Books (模拟)
2019-04-30
ACM 2016 沈阳区域赛 E - Counting Cliques (dfs)
2019-04-30
ACM 2017 北京区域赛 J-Pangu and Stones(区间dp)
2019-04-30
HDU - 5643 King's Game (约瑟夫环变式)
2019-04-30
UVA - 1452 Jump (约瑟夫环变式)
2019-04-30
POJ - 3517 And Then There Was One (约瑟夫环变式)
2019-04-30
HDU - 2068 RPG的错排 (错排+组合数)
2019-04-30
CodeForces 591C Median Smoothing(思维 模拟)
2019-04-30
升级yosemite后java出错的解决
2019-04-30
两台服务器之间拷贝文件-scp方法
2019-04-30
PostgreSQL中 drop table指令出现ERROR: cannot drop table userinfo because other objects depend on it
2019-04-30
YModem协议理解
2019-04-30
Java中,jsp文件编译之后部署显示中文乱码
2019-04-30
PostgreSQL之通过数据库模型生成数据库表
2019-04-30
Mac电脑终端下查看电脑信息的相关指令
2019-04-30
使用lshw工具查看linux的系统硬件信息
2019-04-30
Mac NTFS 解决方法
2019-04-30