Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓AlertDialog赢得';t显示_Android - Fatal编程技术网

Android 安卓AlertDialog赢得';t显示

Android 安卓AlertDialog赢得';t显示,android,Android,我有一个通过警报对话框显示欢迎屏幕的应用程序。我在活动的onCreate方法中使用以下代码: wsBuilder = new AlertDialog.Builder(this); wsBuilder.setIcon(android.R.drawable.ic_dialog_alert); wsBuilder.setTitle(R.string.instructions_title); wsBuilder.setMessage(R.string.welcome_1); wsBuilder.setP

我有一个通过警报对话框显示欢迎屏幕的应用程序。我在活动的onCreate方法中使用以下代码:

wsBuilder = new AlertDialog.Builder(this);
wsBuilder.setIcon(android.R.drawable.ic_dialog_alert);
wsBuilder.setTitle(R.string.instructions_title);
wsBuilder.setMessage(R.string.welcome_1);
wsBuilder.setPositiveButton(R.string.ok,
    new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which) {
          dialog.dismiss();
      }
    });
wsBuilder.show();
当我启动应用程序时,大多数时候屏幕会变暗,就像对话框将要打开时一样 显示,但该对话框从未显示。屏幕一直变暗,任何触摸事件都无法通过。我可以点击手机上的“后退”按钮关闭对话框,然后应用程序就可以正常工作了,但我不明白为什么对话框不能完全显示出来。对话框偶尔会显示,但大多数情况下不会显示


如果您能帮助解决此问题,我们将不胜感激。

OnCreate可能不是它的最佳位置,因为应用程序正在加载,请尝试在启动时使用它

public void onStart()
{
    //Your code here
}

活动对于wellcome屏幕来说会更好。

我运行了您的代码,在1.6上运行得很好。您是否使用wsBuilder的类型生成器?您在
onCreate()中还做了什么?也许您可以发布
onCreate()
的所有实现?