如何覆盖 Dialog
的 onBackPressed
以关闭对话框以及在 Activity 上调用
finish()
它位于?
How would I override a Dialog
's onBackPressed
to close the dialog as well as calling finish()
on the Activity
it is located in?
可以使用setOnCancelListener
:
dialog.setOnCancelListener(new DialogInterface.OnCancelListener()
{
@Override
public void onCancel(DialogInterface dialog)
{
MyActivity.this.finish();
}
});
您只需完成您的活动.对话框将自动关闭.
You need to finish only your activity. Dialog will be dismissed automatically.
这篇关于覆盖对话框 onBackPressed()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!