如何开始与$ P $ Android中pssing一个按钮后,一些延迟一个不同的活动? [英] How to start a different activity with some delay after pressing a button in android?
本文介绍了如何开始与$ P $ Android中pssing一个按钮后,一些延迟一个不同的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想,一个新的活动应该开始与pressing按钮一些延迟。 是否有可能做到这一点,和最新的程序。
I want that a new activity should start with some delay on pressing a button. Is it possible to do that , and whats the procedure.
推荐答案
您可以使用处理程序postDelayed()方法调用一个Runnable。
You could call a Runnable using the Handler postDelayed() method.
下面是一个例子(http://developer.android.com/resources/articles/timed-ui-updates.html):
Here's an example (http://developer.android.com/resources/articles/timed-ui-updates.html):
private Handler mHandler = new Handler();
...
OnClickListener mStartListener = new OnClickListener() {
public void onClick(View v) {
mHandler.postDelayed(mUpdateTimeTask, 100);
}
};
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
// do what you need to do here after the delay
}
};
道具@mad周边的得到它在第一时间。
Props to @mad for getting it right the first time around.
这篇关于如何开始与$ P $ Android中pssing一个按钮后,一些延迟一个不同的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文