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
1 answer

What am I missing here - in implementing tabs in my activity?

My MainActivity class - where I want to implement fixed tabs package com.nikhil.tabs; import android.app.ActionBar; import android.support.v4.app.FragmentTransaction; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import…
0
votes
1 answer

Fragment is cleared when navigated in FragmentStatePagerAdapter

I have an activity that contains a FragmentStatePagerAdapter within this FragmentStatePagerAdapter there are three fragments. Or well, they get initiated when the proper getItem() is called. The activity does a data intensive task, and when it is…
0
votes
0 answers

cannot create a new Fragment in custom FragmentStatePagerAdapter

I'm trying to pre-populate a FragmentStatePagerAdapter with a list of objects but I cannot instantiate a new fragment. Background: My PagerAdapter consists of an ArrayList of Msg objects (mMsgConvoList). MsgConvoList is an ArrayList of all messages…
0
votes
1 answer

Store data in FragmentStatePager or ViewPager

I have a FragmentStatePager(or a ViewPager) and it contains on every page a ListView.The user should be able to add values dynamically into it. So my question is :What is the best way to store these entries?
0
votes
1 answer

Update view pager indicator from fragment

i'am tryning to update my view pager indicator from my fragment. My problem is the project is structured like this: MainActivity -> FragmentA -> FragmentStatePagerAdapter -> FragmentProduct I've tried implementing an interface in the adapter but the…
0
votes
3 answers

How to save custom ListView entries?

I have two EditText and a ListView inside a FragmentStatePager. Everything works but the entries that I make with the EditText fields into the ListView will be added but when I click back they will not be saved. How is it possible to save them…
0
votes
0 answers

How to pass data from FragmentStatePagerAdapter to the fragment

Hey I want to pass data from FragmentStatePagerAdapter to the fragment. How should I do it ? FragmentStatePagerAdapter public class ScreenSlidePagerActivity extends Fragment { /** * The number of pages (wizard steps) to show in this demo. …
0
votes
1 answer

offscreen viewpager fragments won't render after 1st time loaded

I have a viewpager with 5 tabs and if I go to the 5th fragment(that is the fragment loaded when I click the 5th tab or swipe to the 5th tab) and then I go to the 3rd tab the 5th fragment won't load the view anymore and if I go to the 2nd or 1st tab…
0
votes
1 answer

How to switch which fragments ViewPager displays

Stuck on this for a while; I would really appreciate some help. I have a ViewPager which displays photos and meta data about them (Fragment1). If the user clicks on a photo, I would like to switch to a full screen view (Fragment2). Here's the thing,…
0
votes
2 answers

How to make FragmentStatePagerAdapter from ViewPager fragment and ViewPagerAdapter

I have a ViewPager fragment and a ViewPagerAdapter and I want to make a FragmentStatePagerAdapter. So I searched everywhere but I can't find any good solutions. Can someone help me to make a FragmentStatePagerAdapter of my ViewPagerfragment and my…
0
votes
2 answers

android can't display the fragments in my pager adapter after the third tab

I am using the actionbar tabs in my android application and for some reason the fragments that I want to load after the third tab don't load at all after the first time I change to them regardless of wheather I swipe to them or click on the tab,…
0
votes
2 answers

Android - Problems with BackStack using FragmentStatePagerAdapter

I'm building an Android application using a FragmentStatePagerAdapter for tabbed navigation and dynamic content in each tab. Each tab has Fragment with content which is to be replaced upon user input (for example, the first tab has a Fragment…
0
votes
1 answer

Is it possible to replace the current viewed fragment in FragmentStatePagerAdapter without swiping to other pages first?

I have succeeded replacing fragments in a FragmentStatePagerAdapter but it requires swiping out of the fragment in order for it to be destroyed and re-create a different fragment, thus replacing the fragment. What I need is to replace the current…
0
votes
1 answer

FragmentStatePagerAdapter does not handle changes

I am having a problem managing a changing list of item using the FragmentStatePagerAdapter. Please check source here. The problem is that when the underlying list changes, and I call notifyDataSetChanged, the adapter does not rebuild it's internal…
0
votes
1 answer

FragmentStatePagerAdapter doesn't call getItem on tab reselection

I have a complex UI setup like this: Main Fragment -> Fragment with ActionBar.TabListener -> Fragment with FragmentStatePagerAdapter -> ListFragment This works when the app loads and I go to the Fragment with FragmentStatePagerAdapter the first…
TooManyEduardos
  • 4,206
  • 7
  • 35
  • 66