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

getItem() in FragmentStatePagerAdapter called twice

I have a problem on getItem() method. I had read some of the comment and answer but could not understand on how to implement. Here is my code : public Fragment getItem(int position) { currentItem = position; System.out.println("getItem :…
Nik Faris
  • 35
  • 1
  • 2
  • 7
0
votes
1 answer

How to initialize a ViewPagerAdapter in a Fragment when MainActivity's OnCreate() is called?

I got a Fragment with a ViewPager and I got the FragmentStatePagerAdapter, which is initialized inside the Fragment's OnCreateView() method. To set the data, I created the method setData(List data) inside the Adapter: public void…
0
votes
1 answer

ViewPager with listviews and fragmentstatepageradapter

I have a viewpager with 5 tabs. In each fragment in the viewpager I have a listview that populated with data that I'm getting from server (server calls are done with AsyncTask). I'm also using Fragmentstatepageradapter to have the most smoothly…
Juvi
  • 1,078
  • 1
  • 19
  • 38
0
votes
1 answer

setUserVisibleHint() issue with FragmentStatePagerAdapter

I know this question has already been asked on different website (such as here and there for example, but I struggle to find a solution to my specific use case. Here is the thing: I have 3 tabs (each tabs extends Fragment) which are hosted by an…
0
votes
0 answers

FragmentPagerAdapter and Pager NullPointerException. pager.setOffscreenPageLimit(3)

I have a problem. I have 4 pages. and I used the method that pager.setOffscreenPageLimit(3);... It is very well page swiping. However, When I called finish() at FragmentActivity, Error happened that Fragment BackStack NullPointerException. How do I…
0
votes
1 answer

Last item FragmentStatePagerAdapter

I want to set visible one button in the last page but the last one element don't call the Fragment constructor. ( I debugged it ) public Fragment getItem(int i) { Fragment fragment = new DemoObjectFragment(); Bundle args = new…
user3612445
  • 145
  • 2
  • 16
0
votes
0 answers

Does view pager automatically assign Tag(setTag()) to its fragments?

I am trying to built a view pager ,so when i scroll the next fragments refreshes to accommodate for changes that might have happened to database in previous fragment . my Fragment adapter is : public class inneradapter extends…
0
votes
0 answers

Issue with 2 levels nested ViewPagers driven by a FragmentStatePagerAdapter?

In an Android app, I have a dynamic viewPager, that may display a dynamic number of fragment (the fragment number is fixed before its instantiation). This viewPager is composed of 4 (fixed number) subViewPager. Every subViewPager can hold 1-5…
Anthony
  • 3,989
  • 2
  • 30
  • 52
0
votes
1 answer

SlidingUpPanel loads wrong panel with FragmentStatePagerAdapter

I'm having a problem using SlidingUpPanel (https://github.com/umano/AndroidSlidingUpPanel) and FragmentStatePagerAdapter. I have 3 fragments in the pager: the first two with a sliding panel (one a fragment and one a hardcoded layout) and the third…
Jack
  • 171
  • 2
  • 16
0
votes
0 answers

Viewpager Infinity change from page 1 -> 2 , 2 is not inflate

After searching for many way to take viewpager to infinity with smooth. I found the way do it by: set count of data is max ( Integer.MAX_VALUE) in getItem method(): return data % CURRENT_DATA_SIZE. ( my fragment is 6) Ok then it normally infinity…
kemdo
  • 1,429
  • 3
  • 15
  • 29
0
votes
0 answers

android app set control value of Fragment ParcelableArrayList

Help me Everyone, I can get a ParcelableArrayList of Fragment, but cannot get value of Control in onCreateView() How to set value to Control object? public static class ArrayListFragment extends Fragment { int mNum; int mSEQ; String…
0
votes
1 answer

Creates more items on instantiateItem and not only one as default

I have an adapter (FragmentStatePagerAdapter) with arrows, that each click creates the next page: leftArrow.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { …
0
votes
1 answer

How to save some value and destroy a fragment after swiping?

I have several fragments. I want them to come one after another as ViewPager. If i swipe right then a fragment will be destroyed storing a value "yes" and if i swipe left it will destroy storing a value "no" and next fragment will appear. I tried…
0
votes
3 answers

SetText not working when Changing tabs

I have a SlidingTabLayout and I'm attempting to change a settext every time a different page (Fragment) is selected. I am attempting to do this through the fragments themselves. I have 3 total, and i'm doing so by calling getActivity() in the…
0
votes
2 answers

Refresh middle fragment of viewpager

I have 3 fragment in a viewpager which implemented from FragmentStatePagerAdapter. I want only middle fragment refreshed, because I have an animation listener in it. Because of this I tried this code: @Override public int getItemPosition(Object…