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

Select particular position of dot #57

Closed
akankshapaul048 opened this issue Sep 12, 2019 · 11 comments
Closed

Select particular position of dot #57

akankshapaul048 opened this issue Sep 12, 2019 · 11 comments
Assignees
Labels
Milestone

Comments

@akankshapaul048
Copy link

View Pager + WormDotsIndicator
The viewpager is selected to current item (which can be any position), but I am not able to select the dot indicator to that position of viewpager programatically.

image

@tommybuonomo
Copy link
Owner

Hi @akankshapaul048 ,
If you call setCurrentItem() on your ViewPager, the dots will automatically refresh

@akankshapaul048
Copy link
Author

Well i did that but no changes

@edChori
Copy link

edChori commented Oct 24, 2019

Try this
Handler().postDelayed({viewPager.setCurrentItem(1, true)}, 100)

@oliverspryn
Copy link

oliverspryn commented Nov 15, 2019

Correct, this is still a problem, unless you setCurrentItem with an animation.

viewPager.setCurrentItem(1, true)

@vkotovv
Copy link

vkotovv commented Dec 25, 2019

@tommybuonomo any updates on this?

@SamadiPour
Copy link

Handler().postDelayed({viewPager.setCurrentItem(1, true)}, 75) worked but i want it without this!
is there any other way?

@wachidsusilo
Copy link

wachidsusilo commented Jun 7, 2020

@SamadiPour This worked for me:

    private void buildViewPager(){
        ....
        viewPager.setCurrentItem(0); //this goes to onCreate() method
    }

    private boolean onStart = true;
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        if(onStart){
            onStart = false;
            viewPager.setCurrentItem(initialPosition, false); //set initial position you want
        }
    }

@krodyrobi
Copy link

Hello, we've hit this as well.

Both the Spring and Worm implementations have the same buggy behavior, on a dark mode switch it selects the 1'st dot but the adapter reports position 3 as the currently active item.
It does not happen on the Dots one, and that is a shame as Worm is so cool.

Debugging the override fun onPageScrolled(selectedPosition: Int, nextPosition: Int, positionOffset: Float) callback of worm we see the correct nextPosition but since the dots are not present (only 1 is rendered) it cannot compute the offset to scroll to.

vp.setCurrentItem(pos, smooth) only works correctly for Dots not for the other 2.
In our case we use flow and no matter the delay we use we cannot get it to work.

Dot state recovers on next / prev page navigations or on adapter changes.
Can you guys have a look at it?

@AntonShynkaretskyi
Copy link

It's still the problem. Indicator doesn't update it's state correctly, and I don't see a way to set currentItem manually

@tommybuonomo
Copy link
Owner

Duplicate of #126

@tommybuonomo tommybuonomo marked this as a duplicate of #126 Apr 30, 2022
@tommybuonomo tommybuonomo added bug and removed question labels Apr 30, 2022
@tommybuonomo
Copy link
Owner

Hello there, thanks everyone for your contribution
This will be fixed in the 4.3 release

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

No branches or pull requests

9 participants