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
}