我有一个AlertDialog.Builder,但问题是当AlertDialog.Builder显示时我无法点击工具栏因为AlertDialog.Builder被绘制在所有其他视图之上..我如何使这个AlertDialog.Builder不取消但仍然可以点击工具栏项目。
的快照这是我的代码:
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
//Set title
builder.setTitle("Approval Pending")
//Set message
.setMessage("Your account with Reference Id [" + jObj0.getString("reference_id") + "] is in Pending state.")
.setNegativeButton("REFRESH", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if(Utils.isConnected(getContext())) {
dialog.dismiss();
fetchdashboardfragmentdata(true);
}else{
builder.show();
Toast.makeText(getContext(), "Please turn on your Internet connection and try again", Toast.LENGTH_SHORT).show();
}
}
})
.setPositiveButton("LOGOUT", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
StoreSharePreference.SSP().logout(getContext());
Intent intent = new Intent(getContext(), Login_Page.class);
intent.setFlags(intent.FLAG_ACTIVITY_CLEAR_TOP | intent.FLAG_ACTIVITY_NEW_TASK | intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
getActivity().finish();
}
})
.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
return true;
}
return false;
}
})
.setCancelable(false);
AlertDialog alert = builder.create();
alert.show();
- 我希望能够在AlertDialog.Builder显示时点击购物车图标,图标和导航抽屉.--
答案 0 :(得分:0)
您无法触摸警告对话框后面的元素,因为对话框始终覆盖您的活动。在触摸活动UI组件之前,您必须先关闭对话框。
答案 1 :(得分:0)
您可以使用
AlertDialog helpDialog = alert.create();
Window window = helpDialog.getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
window.setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);