Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

导航栏默认选中项的问题 #272

Open
yilylong opened this issue Aug 10, 2021 · 0 comments
Open

导航栏默认选中项的问题 #272

yilylong opened this issue Aug 10, 2021 · 0 comments

Comments

@yilylong
Copy link

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赋值方法才行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant