gpt4 book ai didi

android - 不显示普通 Android 应用程序中的对话框?

转载 作者:太空狗 更新时间:2023-10-29 16:22:50 25 4
gpt4 key购买 nike

我有以下应用程序。我正在尝试做一件非常简单的事情。只是在启动时显示警报。但它只是显示这条消息

"[2012-04-13 17:38:23 - HelloDriod] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=hellodriod.hello/.HelloDriodActivity }
[2012-04-13 17:38:23 - HelloDriod] ActivityManager: Warning: Activity not started, its current task has been brought to the front"

在模拟器上我只看到项目名称和空白屏幕。我错过了什么吗?任何指示表示赞赏。

package hellodriod.hello;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;



public class HelloDriodActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {

}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();

}
}

最佳答案

您实际上没有显示对话框。

alert.show();

关于android - 不显示普通 Android 应用程序中的对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10148687/

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