本文介绍了如何显示在Android的欢迎画面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我想这应该出现2-3秒,我的标志,然后应着手主程序的屏幕。
Hi I want a screen which should appear for 2-3 seconds with my logo and then it should proceed to the main program.
我怎样才能实现呢?
推荐答案
下面是一个简单的闪屏实现:
Here is a simple splashScreen implementation:
public class SplashScreen extends Activity {
private Handler mHandler;
private long delay = 1000;
private int i = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splash_screen);
Timer timer = new Timer();
timer.schedule(task, delay);
}
TimerTask task = new TimerTask() {
@Override
public void run() {
Intent in = new Intent().setClass(SplashScreen.this,
LoginActivity.class).addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(in);
finish();
}
};
}
变量延迟表示切换到另一个之前,您的SplashScreen活动的暂停时间。
The variable delay indicates the pause time of your splashScreen Activity before switching into another.
这篇关于如何显示在Android的欢迎画面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!