tommybuonomo/dotsindicator

Is it possible to use this with mutable fragment lists with view pager 2?

kaushalyap opened this issue · 7 comments

Is it possible to use this with mutable fragment lists with view pager 2? Does number of dots automatically get updated when we remove/add fragments?

Hi @kaushalyap , as long as you have a ViewPager2, you can

I thought it auto update # dots when # fragments changes, currently I set the viewpager again when # fragments changes

ex:

binding.btnNext.setOnClickListener {
            viewPagerAdapter.removeFragment(2)
            binding.dotsIndicator.setViewPager2(binding.vpHabitSteps)
} 

Can you guys make this automatic? (# dots adjust to # fragments)

What's inside your removeFragment () method ? Maybe you forgot to call notifyDataSetChanged inside right ?
The refresh is automatic, you don't have to set the ViewPager again if you notify your adapter that the items changed

@tommybuonomo

I have following

 fun removeFragment(position: Int) {
        fragmentList.removeAt(position)
        notifyItemRemoved(position)
 }

It does work(automatically update # dots) with notifyDataSetChanged, But does not work with notifyItemRemoved(position) why does it does not work with notifyItemRemoved(position)?

Related issue - #73

Hello, thanks for your contribution !
This issue is now fixed in the new version 4.3
Thanks 🔥