new
AlertDialog.Builder(
this
).setPositiveButton(
new
String(
"
确定
"
),
new
DialogInterface.OnClickListener() {
@Override
publicvoid
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();
}
}
}
AlertDialog 点击按钮后不关闭的处理办法
最新推荐文章于 2023-05-26 14:38:23 发布