gpt4 book ai didi

java - 从 onOptionsItemSelected 显示对话框

转载 作者:行者123 更新时间:2023-12-01 22:11:41 25 4
gpt4 key购买 nike

我试图从菜单工具栏显示我的 AlertDialog,但此代码出现此异常:

case R.id.about: {
final AlertDialog.Builder aboutDialog = new AlertDialog.Builder(SplashActivity.this);
aboutDialog.setTitle(mCtx.getResources()
.getString(R.string.about_tests))
.setCancelable(true)
.setMessage(mCtx.getResources().getString(R.string.description_tests))
.setPositiveButton(mCtx.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int arg1) {
googleRateClick();
}
})
.setNegativeButton(mCtx.getResources().getString(R.string.not_now), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int arg1) {
dialog.dismiss();
}
});

aboutDialog.show();
}
1433-1433/MYPACKAGE E/WindowManager﹕ android.view.WindowLeaked: Activity MYPACKAGE.activity.SplashActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{d3dca6c V.E..... R......D 0,0-729,665} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:363)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:261)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:298)
at android.app.AlertDialog$Builder.show(AlertDialog.java:987)
at MYPACKAGE.SplashActivity.onOptionsItemSelected(SplashActivity.java:90)

最佳答案

您忘记了 case 语句中的 break; 指令。我认为这是你的问题。您不妨检查是否调用 finish(); 方法,因为此错误通常告诉您对话框是从关闭的 Activity 中显示的

关于java - 从 onOptionsItemSelected 显示对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31708795/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com