Hi, I need to update all the fragments of the viewpager. I do this through setAdapter(adapter); But after the update, PagerTitleStrip disappears. When you swipe to another page, the viewpager PagerTitleStrip restored.

How can this happen? Do I need to delete all the ViewPager pages before updating it through the setAdapter ?

  • you need more information, preferably pieces of the code itself, what happens inside your Adapter , the onCreateView fragment in which the adapter is located (how is the adapter created)? - Leo K
  • or at least show that you transmit to the Adapter constructor - Leo K

2 answers 2

Since there is not enough information yet, I will assume that you are using fragments inside fragments. In this case, when creating an Adapter it should transfer getChildFragmentManager() instead of getSupportFragmentManager() .

  • so I pass on - user3750141

maybe you should not use the adapter You are going to update the fragments ... the viewpager does not have to be refilled ... for example, you can get all your fragments and update them (call onCreateView, well, or another method, where the data of your fragments are initiated)

  • when updating, the number of fragments can change - user3750141
  • but it does not matter ... you also have a collection of fragments ... can you get them all and update them in a cycle ... or do you have them in principle destroyed and other fragments are formed? - evp
  • fragments are the same, only for example, if I previously had 2 fragments, then when they are updated, it can become 3 and vice versa. Those. When I upgrade, the number of fragments is added or deleted. - user3750141
  • Do you have an adapter - the one that parameter here "setAdapter (adapter);" This adapter has a getCount () method - this will get the number of fragments. in the loop, loop through them again using the getItem () adapter method - this is how you get your fragment, and call it onCreateView - evp
  • And if I need to change the number of fragments? - user3750141