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
4
votes
0 answers

IllegalStateException : PagerAdapter changed the adapter's contents without calling PagerAdapter notifyDataSetChanged

When should notifyDataSetChaned be called? I am using FragmentStatePagerAdapter. I have one item in my dataset. I add a new item to my dataset. But I do not make any changes to viewPager. No touch event or any user generated event is passed. I call…
4
votes
0 answers

ViewPager + FragmentStatePageAdapter : what does this warning "not updated inline" mean?

My app consists of a ViewPager with a FragmentStatePageAdapter. Since I have updated to Lollipop / AppCompat I am getting these warnings everytime I swipe the page (on my previous test devices based on KitKat/Holo I didn't get any…
rupps
  • 9,712
  • 4
  • 55
  • 95
4
votes
0 answers

Destroyed and Detached fragment not Garbage collected / still exists

I have a fragment that hosts a a ViewPager populated by a FragmentStatePager adapter. The child fragment consists of an a square ImageView the width of the phone's screen and TextView showing a user's name. The purpose of this fragment is to allow…
4
votes
1 answer

Second set of tabs in an Android fragment

I want to add a second row of tabs to my Android application on the second fragment accessed from the ActionBar tabs. Tab 1 shows fragment 1. Tab 2 shows fragment 2 but I would like fragment 2 to have a second row of tabs so it will show fragment…
4
votes
1 answer

Cannot instantiate the type PagerAdapter

I am working with fragments and pageview trying to use a horizontal pager and i got the following error: Cannot instantiate the type PagerAdapter. I know that PagerAdapter is an abstract class, so i created a new class that inherits from…
4
votes
2 answers

ListFragment doesn't re-display data when calling it from FragmentStatePagerAdapter

Here's my UI hierarchy: Main Fragment -> Fragment with ActionBar.TabListener -> Fragment with FragmentStatePagerAdapter -> ListFragment The issue is that the ListFragment does display the first time I go into the tab of the ListFragment, but it does…
4
votes
1 answer

How to add Fragment to the middle of FragmentStatePagerAdapter

I wanna add the Fragment to the middle of FragmentStatePagerAdapter with PagerSlidingTabStrip. But I can add the new Fragnent only in the end fo Adapter. Here is the code: public class TabsPagerAdapter extends FragmentStatePagerAdapter { private…
4
votes
0 answers

Android listview in a viewpager not showing results

I am new to android. I am using a viewpager with 4 pages and there is a list view in the first page. When I run my app, the list does not display any items but when I switch three pages and come back to the first one, the listview shows up. I tried…
4
votes
1 answer

FragmentStatePagerAdapter, childFragmentManager and orientation change a bad combination?

Here is my the problem, I have an activity, which includes a Fragment that has a ViewPager using (FragmentStatePagerAdapter), all works perfect when the Activity loads for the first time, but when setting setRetainInstance(true) to the parent…
4
votes
1 answer

Fragments not getting recreated by FragmentStatePagerAdapter after coming back to the main Fragment instance

SCOPE I am making an application for my college fest which shows events for 4 particular fixed dates. I have a main_activity which has a linearlayout on which each and every fragment is displayed. Now a I have a Fragment…
4
votes
1 answer

Fragment in ViewPager on Fragment doesn't reload on orientation change

I am working on developing an Android application which uses ActionBarSherlock and ViewPagerIndicator. The main activity is a SherlockFragmentActivity and users navigate between the fragments via tabs on the action bar. All of the tabs are…
4
votes
2 answers

After rotation, fragment transaction gives IllegalStateException

I have an issue with Fragments and BroadcastManager. In my application I switched to one main activity and use the new NavigationDrawer. All content is contained in fragments. One Fragment (Searching for users) contains two tabs (Search By Name,…
4
votes
1 answer

Prevent ViewPager from always instantiating Fragment at position 0?

I'm using a FragmentStatePagerAdapter and ViewPager, and the default starting page is 0. I want mine to start on some arbitary page, say 5. This is how I display my ViewPager: viewPager.setAdapter(adapter); viewPager.setCurrentItem(viewNumber,…
4
votes
1 answer

FragmentPagerAdapter and FragmentStatePagerAdapter

I am currently thinking which implementation of PagerAdapter should I use. I've got dilemmas connected to both of them. Let me show you what are these. 1# FragmentPagerAdapter Works fine, It creates new instances of fragments when none previous…
4
votes
2 answers

FragmentStatePagerAdapter OutOfMemoryError

I'm running into OutOfMemoryErrors in an app that I'm working on and I'm having difficulty figuring out how to fix it and what exactly the issue is. I'm using the FragmentStatePagerAdapter, since that seemed like the best/recommended alternative.…