如何覆盖 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模板网!
使用 GPS 获取用户的当前位置Get user#39;s current location using GPS(使用 GPS 获取用户的当前位置)
requestLocationUpdate() 抛出的 IllegalArgumentExceptionIllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 抛出的 IllegalArgumentException)
LocationManager 的 getLastKnownLocation 有多可靠,多久更How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新
如何检测位置提供者?GPS 或网络提供商How to detect Location Provider ? GPS or Network Provider(如何检测位置提供者?GPS 或网络提供商)
在应用启动期间获取当前位置Get current location during app launch(在应用启动期间获取当前位置)
locationManager.getLastKnownLocation() 返回 nulllocationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)