Skip to content

不支持setCurrentItem(index, false)? #290

Open

Description

@zhongzixing

setCurrentItem(index, false)光标不移动,另外初始化Viewpager其他index。选中tab也无法准确选中

Activity

  1. hackw commented on Sep 1, 2022

    @hackw
  2. prohack commented on Dec 13, 2022

    @prohack

    绑定了依然会出现这问题,如果是setCurrentItem(index, true)光标则会正常移动,很头疼

  3. prohack commented on Dec 13, 2022

    @prohack

    你绑定了吗? zhongzixing @.> 于2022年8月26日周五 16:45写道:
    …
    setCurrentItem(index, false)光标不移动,另外初始化Viewpager其他index。选中tab也无法准确选中 — Reply to this email directly, view it on GitHub <#290>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFJNWTMJH32PRI2FUR7WGZLV3B73VANCNFSM57V42J4Q . You are receiving this because you are subscribed to this thread.Message ID: @.
    >

    使用的viewpager2,自己手动绑定的,依然会出现这问题,如果是setCurrentItem(index, true)光标则会正常移动,很头疼

  4. prohack commented on Dec 13, 2022

    @prohack

    你绑定了吗? zhongzixing @.> 于2022年8月26日周五 16:45写道:
    …
    setCurrentItem(index, false)光标不移动,另外初始化Viewpager其他index。选中tab也无法准确选中 — Reply to this email directly, view it on GitHub <#290>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFJNWTMJH32PRI2FUR7WGZLV3B73VANCNFSM57V42J4Q . You are receiving this because you are subscribed to this thread.Message ID: @.
    >

    解决了,如果不需要滑动动画的话,则需要手动在onPageSelected之前进行onPageScrolled(position,0f,0)就可以了

  5. zl277287818 commented on Apr 24, 2023

    @zl277287818

    viewPager.setCurrentItem(index,false);
    magicIndicator.onPageScrolled(index,0,0);

  6. minorlai commented on Aug 23, 2023

    @minorlai

    绑定了依然会出现这问题,如果是setCurrentItem(index, true)光标则会正常移动,很头疼

    一样遇到这问题啊,怎么解决,绑定viewpager点击tab切换fragment,setCurrentItem(index, false),就没有动画,
    setCurrentItem(index, true)就正常有动画
    @hackw @zhongzixing @prohack @zl277287818

  7. minorlai commented on Aug 23, 2023

    @minorlai

    发现demo 的 LoadCustomLayoutExampleActivity 类也是这样:
    commonPagerTitleView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(index, false); } });

    .setCurrentItem(index, false); 点击底部菜单就没有动画了 @hackw

  8. zcqzcq commented on May 9, 2025

    @zcqzcq

    你绑定了吗? zhongzixing @.> 于2022年8月26日周五 16:45写道:
    …
    setCurrentItem(index, false)光标不移动,另外初始化Viewpager其他index。选中tab也无法准确选中 — Reply to this email directly, view it on GitHub <#290>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFJNWTMJH32PRI2FUR7WGZLV3B73VANCNFSM57V42J4Q . You are receiving this because you are subscribed to this thread.Message ID: _
    @**
    .**_>

    解决了,如果不需要滑动动画的话,则需要手动在onPageSelected之前进行onPageScrolled(position,0f,0)就可以了

    这样子指示器是能指定新的tab了 但是文本的颜色没变化,需要在onPageSelected之后调用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions