如何禁用所有对话框和布局中的后退按钮?
How to disable back button in all dialogs and layouts?
在我的代码中:
@Override
public void onBackPressed() {
}
它工作正常,但是如果我调用一个对话框,例如
final Dialog dialogPopupGewonnen = new Dialog(Start.this, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
dialogPopup.setContentView(R.layout.popup);
我可以使用后退按钮(后退按钮关闭对话框弹出窗口)。但是我想禁用所有布局和对话框中的后退按钮。
您应该在所有活动中覆盖 onBackPressed,对于 Dialog,您可以使用 setCancelable(false),例如:
final Dialog dialogPopupGewonnen = new Dialog(Start.this, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
dialogPopup.setContentView(R.layout.popup);
dialogPopup.setCancelable(false);
在我的代码中:
@Override
public void onBackPressed() {
}
它工作正常,但是如果我调用一个对话框,例如
final Dialog dialogPopupGewonnen = new Dialog(Start.this, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
dialogPopup.setContentView(R.layout.popup);
我可以使用后退按钮(后退按钮关闭对话框弹出窗口)。但是我想禁用所有布局和对话框中的后退按钮。
您应该在所有活动中覆盖 onBackPressed,对于 Dialog,您可以使用 setCancelable(false),例如:
final Dialog dialogPopupGewonnen = new Dialog(Start.this, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
dialogPopup.setContentView(R.layout.popup);
dialogPopup.setCancelable(false);