我正在为我创建的练习应用程序创建一个简单的启动画面。我有一堆不可见的图像,我希望在延迟5秒内显示,并使用Handler Runnable进行设置。这是到目前为止我的代码:Android - 使用Handler Runnable显示视图
long secondsDelayed = 5;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//I want to display this images in 2 second count
ivLogoText.setVisibility(View.VISIBLE);
ivLogoStem.setVisibility(View.VISIBLE);
//I want to display this image in 3 second count
ivSmLeaves.setVisibility(View.VISIBLE);
//I want to display this image in 4 second count
ivMedLeaves.setVisibility(View.VISIBLE);
//I want to display this image in 5 second count
ivLargeLeaves.setVisibility(View.VISIBLE);
startActivity(new Intent(SplashScreen.this, HomeLeftPanel.class));
finish();
}
}, (long) (secondsDelayed * 1000));
}
从我现在的代码,启动画面停留5秒这正是我所想要的,但所有的图像会以5秒计数显示了太多。有人可以帮我弄这个吗?
我该怎么做@Maddy? – 2014-08-29 04:09:54
http://developer.android.com/reference/android/os/Handler.html#postDelayed(java.lang.Runnable,long) – yiati 2014-08-29 04:32:08
Thanks @Maddy。它工作得很好。我只是需要浏览更多,但适当的执行这个。推荐一些新手阅读? – 2014-08-29 04:45:02