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
1
vote
0 answers

getChildCount() in ViewPager

I'm trying to understand how viewpager works by breaking down the source and I got to the dataSetChanged method. I got to the dataSetChanged method and within it is this piece of code. if (needPopulate) { // Reset our known page widths;…
1
vote
3 answers

How to replace fragment from ViewPager with a new one

I found so many similar questions and so many different answers, but none of them helped me. I will try to post a clear question to get a clear answer if it's possible. So I have an Activity that has a ViewPager with FragmentStatePagerAdapter…
1
vote
0 answers

FragmentStatePagerAdapter does not work with ChildFragmentManager

I have an Activity with a FragmentStatePagerAdapter, but I have to use NavigationView, so I have to move the Activities into fragments to be able to display them contents in the same Activity to be able to navigate between them by the…
1
vote
0 answers

Fragment State Pager Adapter returning wrong saved bundle when change fragment position

I can have the following fragments in a dynamic multi-step sign up form inside the view pager: User wants to sign up as a Company: Page 0 Page 1 Page 2 Page 3 ChooseUserFragment | AddressFragment |…
1
vote
1 answer

How do I dynamically add fragments to start of ViewPager as user reaches the end of the ViewPager?

I currently have a basic ViewPager that utilizes a FragmentStatePagerAdapter to initialize fragments. This ViewPager starts at the end and scrolls backwards (i.e. scrolls to the left). As the user nears the start of the ViewPager's list, I want…
1
vote
0 answers

Fragment with ViewPager that hosts a list of fragments; the ViewPager's setCurrentItem function stops working after I leave the host fragment

My program is designed such that a list of fragments are hosted in MainActivity and navigated through with the FragNav controller library. One of my main fragments has a ViewPager that hosts two other fragments. I've implemented an OnClick interface…
1
vote
2 answers

How can i get current Fragment of FragmentPageAdapter

public class FolioPageFragmentAdapter extends FragmentStatePagerAdapter{ private List mSpineReferences; private Book mBook; private String mEpubFileName; private boolean mIsSmilAvailable; private FolioPageFragment…
avez raj
  • 2,055
  • 2
  • 22
  • 37
1
vote
1 answer

Android Images not appear in Fragment

I made an application extending an activity, all worked fine. To improve the application I changed the activity to Fragment (using onCreateView , onActivityCreated), but now all the images not shown. I don't get any errors. I open the Fragments…
igor
  • 716
  • 1
  • 9
  • 27
1
vote
1 answer

Cannot resolve newInstance

I am learning android development from bignerdranch, I am trying to implement pager adapter but getting error in Android Studio that newInstance method cannot be resolved. I am using support version Fragment library in every class to create…
1
vote
0 answers

onPageSelected called randomly?

I'm currently developing an app which uses a TabLayout with a ViewPager, and have the following problem: sometimes, without any recognizable pattern, the onPageSelected(int position) is called. This is an issue, because the app saves the previous…
1
vote
0 answers

Getting fatal exception while using FragmentStatePagerAdapter

In my app in an Activity there are three tabs with pager effects. I am using FragmentStatePagerAdapter and getting an Exception when the app is opened from the background after 15 minutes of the app being pushed to the background. The…
user7018172
1
vote
2 answers

How to Prevent Android FragmentStatePagerAdapter from Creating Neighboring Fragments

I am creating an Android app, and I have linked aFragmentStatePagerAdapter to a TabBar inside one of my Activities to allow users to slide from Fragment to Fragment. Each Fragment in this Activity is populated by a REST call, and if it fails, a…
user6542934
1
vote
1 answer
1
vote
1 answer

notifyDataSetChanged() forces scroll up in FragmentStatePagerAdapter

I have a FragmentStatePagerAdapter which is being refreshed once every second with new data for some of his pages. The problem is that some pages has a lot of content and a vertical scroll, so every second when notifyDataSetChanged() is being…
1
vote
1 answer

Android layout getting wrapped when keyboard appears

In my application I have two tabs, for which I am using ViewPager, two fragments are within this view pager. Sometimes when I tap on first tabs fragments EditBox keyboard pops, once I am done with the input keyboard disappears. But layout below…
amol anerao
  • 257
  • 1
  • 9