本文介绍了几秒钟(线程/意图)后,给屏幕切换 - Android电子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图做的点击一个按钮,它会显示一个布局的方法。
几秒钟后,我要显示一个新的活动/布局。
I am attempting to making a method that on a button click, it will display a layout.After a few seconds, I want a new activity/layout to be displayed.
这是如何做到这一点任何建议?
Any suggestions on how to do this??
推荐答案
我会建议不要等待UI线程。
I would suggest not to wait on the UI Thread.
您可以使用处理程序
您的任务。在运行
方法将在同一个线程来执行处理程序
已创建:
You can use a Handler
for your Task. The run
method will be executed in the same thread the Handler
has been created:
//delay in ms
int DELAY = 1000;
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(CurrentActivity.this, NextActivity.class);
startActivity(intent);
}
}, DELAY);
这篇关于几秒钟(线程/意图)后,给屏幕切换 - Android电子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!