'Android Studio dynamic ViewPager with dynamic buttons in every page

I have same buttons in every page and can be pressed and unpressed, but when change pages in viewpager my buttons become all unpressed.



Solution 1:[1]

answer 1 You need to prevent the page from refreshing. 5 is number of your pages.

ViewPager view_pager; view_pager.setOffscreenPageLimit(5);

or

answer 2 you have to store buttons state

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hamid-Ghasemi