安卓开发中怎样使安卓程序停留在一个界面2秒后再跳入另一个界面,我想做的是一个欢迎界面的程序,谢谢
2个回答
展开全部
楼主您好~做一个欢迎界面很简单,不用楼上的说的那么麻烦,您只要做一个定时器就行啦,直接给您上代码吧:
public class LoveActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Timer timer = new Timer();
TimerTask task = new TimerTask(){
@Override
public void run() {
Intent intent = new Intent(LoveActivity.this, Welcome.class);
startActivity(intent);
LoveActivity.this.finish();
}
};
timer.schedule(task, 2000);
}
}
就是这么简单,希望能帮到您
public class LoveActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Timer timer = new Timer();
TimerTask task = new TimerTask(){
@Override
public void run() {
Intent intent = new Intent(LoveActivity.this, Welcome.class);
startActivity(intent);
LoveActivity.this.finish();
}
};
timer.schedule(task, 2000);
}
}
就是这么简单,希望能帮到您
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询