Questions tagged [fragmentstatepageradapter]

Implementation of PagerAdapter class from the Android compatibility package that uses a Fragment to manage each page. This class also handles saving and restoring of fragment's state.

This version of the pager is more useful when there are a large number of pages, working more like a list view. When pages are not visible to the user, their entire fragment may be destroyed, only keeping the saved state of that fragment. This allows the pager to hold on to much less memory associated with each visited page as compared to FragmentPagerAdapter at the cost of potentially more overhead when switching between pages.


From the documentation of the FragmentStatePagerAdapter class:

Implementation of PagerAdapter that uses a Fragment to manage each page. This class also handles saving and restoring of fragment's state.

This version of the pager is more useful when there are a large number of pages, working more like a list view. When pages are not visible to the user, their entire fragment may be destroyed, only keeping the saved state of that fragment. This allows the pager to hold on to much less memory associated with each visited page as compared to FragmentPagerAdapter at the cost of potentially more overhead when switching between pages.

When using FragmentPagerAdapter the host ViewPager must have a valid ID set.

Subclasses only need to implement getItem(int) and getCount() to have a working adapter.

Tag Usage:

397 questions
0
votes
0 answers

ViewPager not showing content onResume

I'm using FragmentStatePagerAdapter for TabLayout with a ViewPager going to show a RecyclerView and when I click on a item of my list and i click back to go to previous page It's showing me a blank page with TabLayout and no RecyclerView. Here is my…
0
votes
1 answer

how to maintain backstack of fragment using FragmentStatePagerAdapter

MainActivity containing Navigation drawer. Clicking on navigation drawer item,opening a fragment with viewpager. Clicking on tabs fragment item, another fragment is coming but when pressing back button the viewpager fragment coming blank. How to…
0
votes
1 answer

Android FragmentStatePagerAdapter not updating ViewPager correctly when adding/removing pages

I'm trying to create a browser with tabs that you can easily add, remove, and swipe between. Currently I have a ViewPager with each paged fragment containing a WebView and some buttons. The problem is I can't seem to reliably update the ViewPager…
0
votes
1 answer

getParentFragment() in fragments is returning null when fragment is popped out from backstack

I have an activity containg framelayout, fragment A is hosted with getSupportFragmentManager() in this. This fragment A hosts two more fragments which has recycler views in it -Fragment A1 and Fragment A2 using FragmentStatePagerAdapter. At this…
0
votes
1 answer

Set data from Activity to it's Fragment at runtime on data updated from server

I have another one question about transfering data from Activity to Fragment. In my activity I have next situation: one part of UI is situated in Activity, and another (more dynamic part) is situated in Fragment. The data which I need to populate my…
yozhik
  • 4,644
  • 14
  • 65
  • 98
0
votes
1 answer

Android FragmentStatePagerAdapter - Overlap of Fragments after switching Tabs

I have some problems with overlapping Fragments. I use a TabLayout with a FragmentStatePagerAdapter and 3 Tabs (Fragments with ListView). If I change the tabs while i processing data in background and go back to the first tab there are two…
Neo1989
  • 21
  • 3
0
votes
0 answers

Putting views with a viewPager in the same xml file

This is my first question on Stackoverflow, so forgive me if my asking way or my English aren't good. I have imageView and textView, they are in the same XMLfile with my viewPager. But they didn't appear on my screen because of the viewPager. So…
0
votes
0 answers

ViewPager with FragmentStatePagerAdapter scrolls before closing

I have a ViewPager with a FragmentStatePagerAdapter to let users scroll through videos using a VideoView. It works fine, but when you press the back button, the viewpager scrolls to the left and briefly shows the previous ViewView before closing the…
Parker
  • 8,539
  • 10
  • 69
  • 98
0
votes
0 answers

How to update fragment when switching between tabs using FragmentStatePagerAdapter?

I am trying to get a tab layout working with a common fragment, which gets passed an argument string called category, which is used for filtering a query to be displayed in the activity, depending on the tab position. This is my…
0
votes
2 answers

Fragment has not been attached yet when rotating the activity

I'm creating an Activity with ViewPager that using FragmentStatePagerAdapter. But when I'm trying to rotate my phone, it crash and come with error "Fragment has not been attached yet" Here's my adapter: public class SalesPagingAdapter extends…
0
votes
2 answers

Swiping to previous fragment restarts app using ViewPager and FragmentStatePagerAdapter

After adding a ViewPager and FragmentStatePagerAdapter, the new CrimePagerActivity does start and I can swipe forward normally, but if I try to swipe to the Crime where I came from, the app freezes for a second then restarts the app back to the list…
0
votes
0 answers

Activity with FragmentStatePageAdapter missing data on restart (after being destroyed)

I have a MainActivity (MA) and a DetailActivity (DA), where MA contains a CursorLoader displayed in a grid (RecyclerView). If the app goes to the background (and is possibly destroyed) and then restarted/restored, then MA is always re-initialized on…
0
votes
1 answer

TabLayout fragments are instantiated as the same when debugger is not connected

I have a TabLayout that uses a custom adaptor (TabPagerAdapter.java), it's initialised with this function (I previously had the problem that things didn't update when replaced so it removes everything before initializing): public boolean…
0
votes
1 answer

Animation on notifyDataSetChanged() in FragmentStatePagerAdapter

By overwriting getItemPosition() method I can refresh my FragmentStatePagerAdapter, which works fine. But the change of the contents is not nice to see. Is there possibility to apply any kind of animation as I refresh the FragmentStatePagerAdapter?
0
votes
0 answers

FragmentStatePagerAdapter and ViewPager

I am trying to implement an activity with a button. This button, when pressed, will take you to the first page of a ViewPager. Sounds simple enough, right? I'm a bit confused as to how the ViewPager and the FragmentStatePagerAdapter (FSPA) work,…