对话框消息之前的启动屏幕
我希望在弹出对话框之前显示启动画面几秒钟。但是,当我加载应用程序时,对话框和背景屏幕同时显示。我可以做什么来在对话框出现之前显示我的splash.xml 的背景图像。
Thread waitabit=new Thread(){
public void run(){
try{
sleep(2000);
}catch(Exception e){
e.printStackTrace();
}
}
};waitabit.start();
将以上内容放在我的对话框之前只会使其变黑 2 秒钟,然后立即显示所有内容。在线程内调用我的对话框会导致错误,因为我们无法将对话框放入线程中。
谢谢
I want to have a splash screen show up for a few seconds before a dialog pops up. However when I load my app the dialog and the background screen show up at the same time. What can I do to show the background image of my splash.xml before the dialog appears.
Thread waitabit=new Thread(){
public void run(){
try{
sleep(2000);
}catch(Exception e){
e.printStackTrace();
}
}
};waitabit.start();
Putting the above before my dialog just makes it dark for 2 seconds before showing everything all at once. Calling my dialog inside of the thread causes and error because we cant put dialogs in a thread.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试将上述代码放入 AsyncTask 中,以便 UIThread 不会休眠。
Try putting the above code in an AsyncTask so that the UIThread does not sleep.
此链接对于如何显示启动屏幕并调用一次处理程序有一个非常好的解决方案初始屏幕已完成(即这将允许您显示对话框)。
This link has a pretty good solution on how to show a splash screen and call a handler once the splash screen is finished (i.e. this would allow you to display your dialog box).
一个显示闪屏的活动怎么样,然后通过对话框启动该活动?
http://www.codeproject.com/KB/android/AndroidSplash.aspx
How about an activity to show the splash screen that, in turn, launches the activity with the dialog?
http://www.codeproject.com/KB/android/AndroidSplash.aspx
在你的 onResume 中试试这个:
Try this in your onResume: