在我的应用程序中,我在onCreate中设置了所有内容,然后启动了一个异步任务,该任务设置加载我的所有资源等……在异步任务启动后,我将启动屏幕添加到我的布局中。加载完所有内容后,启动画面会消失,我的 Open GL 渲染器会显示在下方。
我正在尝试做的是添加一个对话框屏幕(基本上,另一个显示位图的View类)。而且,在用户按下我的对话屏幕中的屏幕之前,我不希望发生任何 Splash 的事情。
它会是这样的(注意,这只是我真实 onCreate 的摘录,但应该足以说明问题)
public void onCreate(Bundle savedInstanceState){
SplashScreen splash = new SplashScreen (getApplication(), width, height);
ConsentDialog consentDialog = new ConsentDialog(getApplication(), width, height);
//Add the consent dialog
layout.addView(consentDialog);
setContentView(layout);
super.onCreate(savedInstanceState);
//Splashscreen
backgroundResources = new MyAsync(newBundle);
backgroundResources.execute();
layout.addView(splash);
}
但是,当我运行上述程序时,它会显示启动画面,加载所有内容,然后关闭启动画面,留下对话框。
如何在 setContentView 之后暂停(或产生暂停效果的东西) onCreate 方法,直到用户点击屏幕?(注意,我正在使用我的许可对话框对象中的 onTouch(View v, MotionEvent event) 方法等待触摸事件。
基本上,异步不应该在用户点击屏幕之前开始。如果无法做到这一点,我该怎么做才能达到我想要的效果?