码迷,mamicode.com
首页 > 其他好文 > 详细

Handler基本用法

时间:2018-02-08 20:23:45      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:public   hand   manage   message   url   send   case   col   实践   

1.
mHandler = new Handler();
mRunnable = new Runnable() {
@Override
public void run() {
currentPosition++;
Log.d("recyclerBanner", currentPosition + " ");
mOverFlyingLayoutManager.scrollToPosition(currentPosition);
// recyclerView.smoothScrollToPosition(currentPosition);
mHandler.postDelayed(this, 3000);
}
};
mHandler.postDelayed(mRunnable, 3000);

2.项目中实践用法
mainHandler.sendEmptyMessageDelayed(Url.Banner,3000);
@Override
protected void disposeMainHandlerCallMethod(Message msg) {
super.disposeMainHandlerCallMethod(msg);
switch(msg.what){
case Url.Banner:
currentPosition++;
Log.d("recyclerBanner", currentPosition + " ");
mOverFlyingLayoutManager.scrollToPosition(currentPosition);
// recyclerView.smoothScrollToPosition(currentPosition);
mainHandler.sendEmptyMessageDelayed(Url.Banner,3000);
break;
default:break;
}//end of switch
}
 

Handler基本用法

标签:public   hand   manage   message   url   send   case   col   实践   

原文地址:https://www.cnblogs.com/dubo-/p/8432506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!