Skip to content
Advertisement

Simple swipe screen using VIewPager2 (Java)

I am trying to create layout which will show three screens which could be changed by swipe or by button. Between those buttons should be dots indicator of selected page.

I spent many time searching of samples how to do it, but usually I stucked on some issue. I don’t need option of dynamical adding of fragments. The best and working solution was thisone, but I wasn’t able to create three different fragments and it was missing the dots indicator.

Could someone help me with this issue? Thank you very much.

Advertisement

Answer

you can just have a new class that extends to FragmentStateAdapter and set the class as the adapter of your viewpager like so:

JavaScript

}

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement