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

ImagePagerAdapter - The constructor is never used locally / The value of the field is not used

I'm having a bit of trouble implementing my ImagePagerAdapter - I believe I have not implemented it correctly due to the following two warnings: The constructor Home.ImagePagerAdapter(Activity, int[], String[]) is never used locally & The value…
0
votes
2 answers

Creating ListView with android.support.v4.view.ViewPager showing nothing

I'm trying to create a ListView that each cell can be shifted as ViewPager. Similar to Google Gmail app, that can shift emails in order to delete the emails. It is working BUT showing nothing. I created a ListView with BaseAdapter. The Adapter…
0
votes
2 answers

Java / Android - Cannot Reach Breakpoint

I'm attempting to implement a viewPager in my source code and I set a breakpoint at the line: if (position > oldPos) { yet for some reason when swiping the viewPager left and right I never seem to reach the breakpoint in the debugger. I've looked…
0
votes
1 answer

Issue with ViewPager inside SherlockFragment

I have created a tabbed control with SherlockFragmentActivity and inside one of the Fragment, I am trying to use the ViewPager. SettingsActivity.java public class SettingsActivity extends SherlockFragmentActivity { SherlockFragment faq = new…
0
votes
1 answer

Swipe views - fixed tabs

I created Swipe Views with Tabs following this official Android tutorial: http://developer.android.com/training/implementing-navigation/lateral.html I'm using a FragmentPagerAdapter to make tabs fixed and all visible. I'm developing on two PCs, on…
Petr B
  • 519
  • 2
  • 6
  • 15
0
votes
2 answers

android - How to show multi words page tile of ViewPager using IconPagerAdapter without getting second word being hidden?

How can I show a page title with more than one word without getting the second one being hidden ? Here is the explanation: The blue tab title is a normal title with one word. The red title label contain 2 words but only 1 is shown. Here comes the…
0
votes
1 answer

Android: FragmentPagerAdapter which includes multiple Fragments in same page

I have been looking for this all day. And I've have read through the Android Developer references aswell. I would like the following structure in my xml. The following LinearLayout…
0
votes
1 answer

How to show a separate fragment in a pager

Based on the default "Fixed Tabs + Swipe" activity in the ADT, I have a FragmentActivity with a FragmentPagerAdapter. The FragementPagerAdapter is very simple (just returns a certain fragment based on the called position) and at the moment the…
Nanne
  • 64,065
  • 16
  • 119
  • 163
0
votes
1 answer

How to set the titles in a ViewPager PagerTitleStrip instantly

I know that I can override the getPageTitle() method of FragmentPagerAdapter: @Override public CharSequence getPageTitle(int position) { return "myTitle"; } ...but I'd like to change to page titles on a CursorLoader callback: @Override public…
cody
  • 6,389
  • 15
  • 52
  • 77
0
votes
1 answer

Replace part of fragment inside of FragmentPagerAdapter

I have a FragmentPagerAdapter with several Fragments which are dynamically created during runtime depending on the user settings. Depending on those user settings a part of each fragment should be replaced with another fragment (sometimes a…
0
votes
2 answers

Color line below title in PagerTitleStrip

I have implemented a FragmentPagerAdapter of 4-pages and a PagerTitleStrip with the titles of each of them. I wanted to know if there are any attributes to put a color line below title to highlight the one selected at the time. I've looked…
KryNaC
  • 379
  • 4
  • 21
0
votes
0 answers

Context type in fragment

I have implemented a FragmentPagerAdapter with 4 tabs and I have associated a fragment to each of them. One of the views loads a GridView with images as follows: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle…
KryNaC
  • 379
  • 4
  • 21
0
votes
1 answer

Interacting with elements from FragmentPagerAdapter

I have implemented a FragmentPagerAdapter with 4 tabs and I have associated a fragment to each of them. The problem is that I can not interact with the elements they contain, I tried the following: @Override public View…
KryNaC
  • 379
  • 4
  • 21
0
votes
0 answers

Spinner's OnItemSelectedListener fired in FragmentPagerAdapter

I'd like to come up with a solution to the following problem: I have a FragmentViewPager holding 4 fragments. The first one holds a Spinner with an OnItemSelected listener which gets triggered at startup (due to how spinners work). Then, if I swipe…
Gonzalo
  • 3,674
  • 2
  • 26
  • 28
0
votes
1 answer

FragmentPagerAdapter implements Parcelable?

My problem I am using ViewPager with custom FragmentPagerAdapter - ThreePageAdapter. ThreePageAdapter consist of 3 pages of WrapperFragment. I use ThreePageAdapter.addFirstPage(Fragment pFragment) to add fragments into ThreePageAdapter. If I…