您的位置:首页 > 其它

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();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: