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

How to add or remove fragments (between existing fragments) in the viewPager?

I am working on a ViewPager with a FragmentStatePagerAdapter and I'm facing some troubles to dynamically add new fragments to my viewPager/Adapter. I have an "add" button where I can press and, then, one new fragment is inserted between other two…
2
votes
1 answer

How to get the Activity in nested fragments?

I'm trying to get the activity calling getActivity() in the fragments contained in a ViewPager and this ViewPager is contained inside a Fragment. I need to call some methods from this activity in those fragments but the getActivity is always…
Dyan
  • 1,703
  • 4
  • 19
  • 26
2
votes
2 answers

Android - Reload Fragment into a ViewPager

I'm building an App which extracts data from a SQLite local database. I have an Activity, in which I use a ViewPager; in this ViewPager, there are 12 swipable Fragments. I'd like to implement a "Reload" button which allows user to reload the actual…
Flash
  • 1,134
  • 10
  • 12
2
votes
1 answer

can't play multiple video using fragment

i'm developing android app that will read an array of mp4 video path and populate each one in a fragment and play them using VideoView. my code works perfectly for the first fragment but not for the rest and i keep getting "Can't play this video"…
2
votes
0 answers

force ViewPager to call getItem when going up the backstack

I'm trying to create an Android application which contains a single activity with a container and a navigation drawer. The initialy empty container loads fragments which has a ViewPager inside a tab layout in which I load a frgment with a…
2
votes
1 answer

Optimize way to use ViewPager?

I'm writing an application where I need to show some 100 page in ViewPager. There are facility to jump from one index to direct any random index page. Here Every page it self contain list of item. Now if I just to user ViewPager.current(index) to…
CoDe
  • 11,056
  • 14
  • 90
  • 197
2
votes
0 answers

fragment transaction independent of view pager

I want to be able to have a fragment that can only be accessed via a button but also still have a sliding view pager with multiple fragments. I don't want to be able to access this fragment via the slider it has to be independent of it while still…
2
votes
1 answer

View pager lost its content while switch to tabs in fragment tab host

I am facing the very weird problem,i found the similar kind of problem over the net but none of the solution helps me to get rid of this. Problem :: I am having a one fragment which have 3 tabs,(tabs created using fragment tab host).Now every tabs…
2
votes
3 answers

Android ViewPager + Fragments with dynamic ListViews

In my app I have activity with tabs (let's say 10 tabs). Each tab page contains Fragment with ListView(data displayed in this ListView is loaded dynamically from my server). I use ViewPagerto display these pages. I don't want to keep all the…
2
votes
2 answers

Fragments in ViewPager turns empty/blank when opening+returning from other fragment + orientation etc

I am trying to construct an application where you can scroll through objects with a ViewPager. The ViewPager holds Fragments, support library due to SDK 9 restriction. The fragments are constructed from data in a bean-object. When I leave the active…
2
votes
0 answers

Best Implementation for OnClickListener with Dynamic Fragments Using FragmentStatePagerAdapter

New(er) to android fragments and developing an app with two areas 80/20 on screen. Within the 80% area, there's an area dedicated to fragments, with each fragment containing one button; the number of fragments is created dynamically, so my ViewPager…
2
votes
0 answers

reordering and adding fragments to FragmentStatePagerAdapter without having to clear items list

I asked this question over a year ago and got some good feedback about how to implement it but that project was abandoned. It has now resurfaced and I'm rekindling this fire. The closest answer I got is here: Android ViewPager: Move any page to end…
2
votes
1 answer

prevent viewPager last page from being selected

I have viewPager with adapter that override onPageSelected , and i want to prevent the view pager from being selected at last page but swipe-able so when the user leave the finger it will return to previous page . what is the best way to achive that…
2
votes
1 answer

Can't swipe to next item inside my detail activity after implementing viewpager

I am trying to swipe item(from listview) in my detail activity using viewpager. I have 20 items in my listview (data parsed from json) Instead of swiping the next/previous item , It's only the same item that I swipe (20 times). here is my…
2
votes
0 answers

Concept and idea behind FragmentStatePagerAdapter

I have created my MainActivity with four tabs as Fragment . Someone guide me to use FragmentStatePagerAdapter and use a ViewPager inside it. I have searched on google but don't find a good resource or I say i didn't understand the concept behind the…
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300