概述
public static void scrollToListviewTop(final XListView listView)
{
listView.smoothScrollToPosition(0);
final Handler handler = new Handler();
handler.postDelayed(new Runnable()
{
@Override
public void run()
{
if (listView.getFirstVisiblePosition() > 0)
{
listView.smoothScrollToPosition(0);
handler.postDelayed(this, 100);
}
}
}, 100);
}
public class TimeTaskScroll extends TimerTask {
private XListView listView;
public TimeTaskScroll(XListView listView){
this.listView = listView;
}
private Handler handler = new Handler() {
public void handleMessage(android.os.Message msg) {
listView.smoothScrollToPosition(0);
};
};
@Override
public void run() {
Message msg = handler.obtainMessage();
handler.sendMessageDelayed(msg, 2000);
}
}
new TimerTask().run();
转载于:https://www.cnblogs.com/yaya-Android/p/4528060.html
最后
以上就是机灵蚂蚁为你收集整理的handler.postDelayed()和timerTask的全部内容,希望文章能够帮你解决handler.postDelayed()和timerTask所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复