viewpager滑动时中间的一闪而过
开发时遇到了这个问题,百思不得其解,后来查看源码
/**
* Set the currently selected page.
*
* @param item Item index to select
* @param smoothScroll True to smoothly scroll to the new item, false to transition immediately
*/
public void setCurrentItem(int item, boolean smoothScroll) {
mPopulatePending = false;
setCurrentItemInternal(item, smoothScroll, false);
}
如果要避免出现中间滑动闪过的现象,只需要传入第二个参数为false即可
case R.id.menu_home:
mViewPager.setCurrentItem(0, false);
break;
case R.id.menu_today:
mViewPager.setCurrentItem(1, false);
break;
case R.id.menu_mine:
mViewPager.setCurrentItem(2, false);
break;
标签:case,false,menu,问题,item,开发,android,setCurrentItem,id
From: https://www.cnblogs.com/pureayu/p/17126115.html