MagicIndicator icon indicating copy to clipboard operation
MagicIndicator copied to clipboard

导航栏默认选中项的问题

Open yilylong opened this issue 2 years ago • 0 comments

NavigatorHelper里面mCurrentIndex没有提供设值的方法,如果viewpager调用了setCurrentItem 导致导航栏默认选中标题跟viewpager的设置不一致。

初始化时候CommonNavigator 里面调用的时候mNavigatorHelper.getCurrentIndex()默认值还是0 与外部viewpager的设置不一致。 @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (mAdapter != null) { preparePositionData(); if (mIndicator != null) { mIndicator.onPositionDataProvide(mPositionDataList); } if (mReselectWhenLayout && mNavigatorHelper.getScrollState() == ScrollState.SCROLL_STATE_IDLE) { onPageSelected(mNavigatorHelper.getCurrentIndex()); onPageScrolled(mNavigatorHelper.getCurrentIndex(), 0.0f, 0); } } }

NavigatorHelper增加一个mCurrentIndex赋值方法才行

yilylong avatar Aug 10 '21 02:08 yilylong