【发布时间】:2015-09-18 20:33:13
【问题描述】:
在我的应用程序中,我在 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) 方法等待触摸事件。
基本上,异步不应该启动直到用户点击屏幕。如果做不到这一点,我该怎么做才能达到我想要的效果?
【问题讨论】:
标签: android asynchronous oncreate program-flow