Questions tagged [fragmentpageradapter]

FragmentPagerAdapter is a subclass of the PagerAdapter class from the Android compatibility package that represents each page, in the ViewPager where is used, as a Fragment.

FragmentPagerAdapter represent each page as a Fragment. This adapter class should be used only when there is a limited number of Fragments to swipe in the ViewPager. Using the FragmentPagerAdapter would require at minimum implementing the getItem()(to return the Fragment for this position) and getCount()(to return the number of Fragments in this adapter) methods.


From the documentation of the FragmentPagerAdapter class:

Implementation of PagerAdapter that represents each page as a Fragment that is persistently kept in the fragment manager as long as the user can return to the page.

This version of the pager is best for use when there are a handful of typically more static fragments to be paged through, such as a set of tabs. The fragment of each page the user visits will be kept in memory, though its view hierarchy may be destroyed when not visible. This can result in using a significant amount of memory since fragment instances can hold on to an arbitrary amount of state. For larger sets of pages, consider FragmentStatePagerAdapter.

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:

602 questions
0
votes
1 answer

Android Activity Layout with Multiple Fragments

I'm new to Android, there's so much unknown that I don't even know which direction to look for solutions.. I hope experienced developers can enlighten me on this.. I have a UI design that is quite different from common Android app layout, most of…
0
votes
2 answers

Tabhost + viewPager + ListView; Different value being passed in bundle android

I have a single listview that is populated with different information depending on the selected tab. What I expect is that historical tab will getPastBookings(), scheduled tab will getFutureBookings() and favorites tab will get…
0
votes
3 answers

FragmentPagerAdapter + BaseAdapter + UIL not Updating

I am trying to setup a tab title strip using swipes to switch between the fragments as demoed in the documentation here. It works, up to a point. The gridview shows all the images as required however, both fragment 1 and fragment 2 are showing the…
0
votes
1 answer

Passing bundled data to a fragment started with viewPager

In Eclipse v22.6.2 an Activity called Act1 is started with an intent. Some data is passed as a bundle by using putExtras. Intent intent = new Intent(MyMain.this, Act1.class); Bundle bundle = new Bundle(); bundle.putString("id",…
0
votes
1 answer

My FragmentPagerAdapter class's constructor is not getting defined in my main activity

I'm trying to implement a Swipe View with Tabs app but my adapter is giving an error. The constructor function is not getting defined in my Main Activity. I have used the getSupportFragmentManager() function as the argument and all my files are…
0
votes
1 answer

how can i get the right value and set in text view with image pager adapter?

What I have is a class called FullImageActivity2 which displays images and I can flip between images with a pager adapter also in this activity I have a TextView which should display an item id for each image and it takes it values from a string…
user3675605
  • 39
  • 2
  • 11
0
votes
2 answers

how to clean up FragmentPagerAdapter on destroy for memory leaks

i have a FragmentPagerAdapter which causes outofmemory error and crush in the handsets since it leaks memory ,there is no room for a new activity. Tablets can handle it works fine but not on the handsets.i have tried the code below, but it couldn't…
Alp
  • 1,863
  • 1
  • 20
  • 38
0
votes
1 answer

save an object on landscape mode in fragment

i am working on an android project but i have a problem with fragment which is used in fragmentpageradapter which it's an adapter for a view pager i have the following code and i am trying to show Writer information on each page (writer is a member…
strings95
  • 661
  • 11
  • 26
0
votes
0 answers

FragmentPagerAdapter and ViewPager. Strange behavior

I have ViewPager with FragmentPagerAdapter to display images from different folders (inside every Fragment item). And i faced with a strange behavior of FragmenPagerAdapter. For the first time, when i create it everything is ok, and i can see…
0
votes
2 answers

Why is my adapter becoming null?

I'm trying to make a ListFragment that will periodically be updated (Calls to update not shown here, but the update function is). Here's the log cat that I'm seeing: 04-05 11:05:44.252: V/QslLogFrag(2690): onCreate() 04-05 11:05:44.256:…
0
votes
1 answer

Fragments not displayed after several swipes

Context: Implementation of an activity swiping with 3 fragments, each fragments quite "heavy" in memory use. Symptoms: After several swipe, right and left fragment are not displayed anymore and replaced by a black empty background. Center fragment…
L. G.
  • 9,642
  • 7
  • 56
  • 78
0
votes
1 answer

how to replace a fragment within a ListViewPagerAdapter.java

I'm using ViewPager in a fragment. It has 3 tabs Here's the code of my fragmentOagerAdapter: @Override public Fragment getItem(final int position) { Fragment fragment = null; switch (position) { case 0: fragment =…
user1026605
  • 1,633
  • 4
  • 22
  • 58
0
votes
1 answer

How does FragmentPagerAdapter manage views in Fragment?

I use a FragmentPagerAdapter in my app. When I switch between different tabs, I want to update the fragment view. I tried as following, however, the view in the fragment is null and I can not update it when tab is switched. Then, how can I update…
ZhangLei
  • 393
  • 1
  • 7
  • 17
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

getArguments() in Fragment is null when FragmentPagerAdapter recreates it

I recently starting using newInstance() methods in all of my fragments after reading that is the right way to do it. I am, however, upset that it is not working the way I expected. My problem is that getArguments() in onCreate(Bundle…
clocksmith
  • 6,226
  • 3
  • 32
  • 45