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

FragmentStatePagerAdapter with subsets of fragments

This problem has ben bugging me for longer than I am willing to admit, so I came here for help. I am, AFAIK, restrained to using a FragmentStatePagerAdapter to display my fragments due to bitmaps and OOMs on Android. I am implementing a game, and I…
larsba
  • 51
  • 5
0
votes
1 answer

Can't make NavigationDrawer & FragmentStatePagerAdapter work thogether

I'm trying to use a NavigationDrawer with FragmentStatePagerAdapter for the navigation of my app. The idea is that when clicking on an item of the NavigationDrawer a new fragment opens with two tabs in it. My problem is that I can't make it work…
0
votes
1 answer

Loading many fragments based on a JSON source using Fragment State Adapter

I have a Fragment State Pager Adapter and a list of Questions which I retrieve from a server as JSON. Does anyone know how I can dynamically (based on the number of questions returned from the server), create many instances of the same fragment, and…
0
votes
1 answer

How to use FragmentStatePagerAdapter or FragmentPagerAdapter when each Fragment will be from a Different Class?

I would like to use FragmentStatePagerAdapter or FragmentPagerAdapter to be able to swipe through 3 different fragments. Each of the individual fragment is from a different class. I am not quite sure where I should create the new object. Should it…
0
votes
1 answer

OnPageSelected never reached, How to get the current visible page in a fragment?

I tried placing the interface in my Activity, my fragment and my FragmentStatePagerAdapter. But in all of them the code never got there. this is what my FragmentStatePagerAdapter looks like since this is my latest try. FragmentStatePagerAdapter…
Shishi
  • 601
  • 2
  • 8
  • 27
0
votes
1 answer

Grid-view is not formed in horizontal-scrolling-pages like home screen when app is in Background or Process is died

I am developing Horizontal Scrolling pages and tabs MY app is working well in all devices in foreground, but when it goes to background, after one hour, the logs saying that Process com.example.myapp has died. When i reopen the app , the gridview…
Gangadhar Nimballi
  • 1,534
  • 3
  • 18
  • 46
0
votes
1 answer

Replace fragment in viewpager is not working

In my project i am using actionbar with swipeable threefragments(tabs with viewpager), i am trying to replace one of the fragment with fourth fragment, but iam not able to get it.. **Below is my code** public class GetRideFragment extends…
0
votes
1 answer

Android ViewPager and FragmentStatePagerAdapter save visual elements values

In my FragmentActvitiy I am using a ViewPager, which I fill by using FragmentStatePagerAdapter. When I try to access the fragment views, with intention to get / update visual elements I get a nullpointer exception. I can access all the fragments and…
0
votes
1 answer

FragmentStatePagerAdapter getCount() is not called

I am using FragmentStatePagerAdapter in my app. My problem is that when I am doing notifyDataSetChanged() it's calling only the getCount() and not the getItem(). the getCount is not returning 0. this is my FragmentStatePagerAdapter: private class…
roiberg
  • 13,629
  • 12
  • 60
  • 91
0
votes
1 answer

Restore Fragment default values onswipe

there are to many threads talking about this but i tried everything and doens't seem to work. My Problem is kinda simple i have a viewpager with 5 fragments pages. Each of this fragment has the same layout only 1 edit text, and the issue is if i…
0
votes
3 answers

Fragments disapear from FragmentStatePagerAdapter

In my app, I am using FragmentStatePagerAdapter with a ViewPager. All is working well except that when I am coming from background and the memory was cleaned. In that case, some of the fragments have disappeared. The disappeared fragments are not…
roiberg
  • 13,629
  • 12
  • 60
  • 91
0
votes
1 answer

Fragment to Fragment communication with FragmentStatePagerAdapter

I'm trying to update the text of my TextView in my FragmentB through the Button in my FragmentA. But whenever I click the Button, nothing happens in my TextView. What could be the problem? Here's my code: Communicator.java: public interface…
0
votes
1 answer

how to save multiple inflated layouts view state in android fragment?

I am developing a tour booking app. In my tour booking page I have two types of forms, one for lead traveller and one for other travellers(That could be an adult or a child). Lead Traveller fields are: Title First Name Last Name Gender Date of…
0
votes
3 answers

How do I display a TextView when a ListView is empty?

I have a ListFragment that returns a ListView. If there are no items in the list, I'd like to display an alternative TextView instead. Supposedly you can add a TextView android:id="@android:id/empty" element within the XML. But... Adding…
0
votes
1 answer

ViewPager - update view after adapter got empty

I'm using a FragmentStatePagerAdapter with a ViewPager. Everything is working fine. If I open my activity with an empty Adapter, the ViewPageris empty, if I add items, the ViewPager updates correctly. BUT, if I open my activity and delete the last…
prom85
  • 16,896
  • 17
  • 122
  • 242