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
11
votes
5 answers

How to Remove Fragment from FragmentPagerAdapter?

I know there are some topics about this here already but I could not find a solution which I could get to work for my case. I have a working sliding gallery using a custom FragmentActivity and FragmentPagerAdapter which holds a list of…
11
votes
1 answer

Fragments in ViewPager not loaded when the containing Fragment is recreated

I have a Fragment MyFragment vith a ViewPager containing more Fragment. It works properly the first time I load MyFragment, but if I go back and recreate it, the Fragments in the ViewPager are not shown because the method…
jul
  • 36,404
  • 64
  • 191
  • 318
11
votes
3 answers

How to update view pager item TITLE dynamically

I have a simple messaging application module. In which, there are two swipable tabs. Received and Sent. Let us say I have 20 messages out of which 10 are unread. So what I am doing is showing the tabs as Received - (10). Now when I read the…
10
votes
1 answer

Cannot refresh/update listview in a fragment from another fragment in ViewPager

I am having a hard time figuring out the next thing. What I have: I have a viewpager and several pages in it. In this question only two of them is important, lets call them Fragment1 and Fragment2 and they are next to each other. Fragment1 contains…
10
votes
2 answers

FragmentPagerAdapter inside Fragment

I'm having a bit of trouble implementing a design based around multiple ViewPagers. At a high level, I have a FragmentActivity with just a FrameLayout as it's content. I have 3 different Fragments that I want to display. All 3 are full screen and…
9
votes
5 answers

Loading Android Google Map fragment managed by ViewPager

I can load a google map into an Android fragment that's within an activity. That has been working fine. But now I want to use ViewPager to navigate between views (class android.support.v4.app.Fragment). It doesn't seem possible to load a…
9
votes
4 answers

Call Tabbed Fragment method from Activity

I have one activity that comprises of three fragments. The fragments use the actionbar tabs using a PagerAdapter. What I want to do is access a method in the active tabbed fragment from the main activity. I have tried the below code but this just…
user2029541
  • 666
  • 3
  • 12
  • 22
9
votes
3 answers

Remove Item + Scroll to Next in Android ViewPager

I have an Activity containing a ViewPager that displays N fragments. Each fragment is showing the properties of an object from an ArrayList in my ViewPager's custom adapter (extends FragmentStatePagerAdapter). The fragment has (among other things) a…
9
votes
3 answers

How to replace Fragment inside ViewPager, using PagerAdapter?

My problem I am using a ViewPager to display fragments inside a FragmentActivity. ViewPager gets fragments from the attached FragmentPagerAdapter. mViewPager = (ViewPager) findViewById(R.id.view_pager); mAdapter = new…
9
votes
1 answer

Problems with FragmentPagerAdapter

I'm trying to make a slidescreen with viewpager and fragments so that I can load different layouts per fragment and give each page different functionality. I followed a tutorial to accomplish this. The error I'm getting when hovering over public…
8
votes
2 answers

Fragment not added (inconsistent crash)

In my MainActivity, I have: @Override protected void onResume() { super.onResume(); checkForCrashes(); checkForTutorial(); checkForUpdates(); setStore(); setup(); } In setup(), I call initializeTabs() in a…
quantumpotato
  • 9,637
  • 14
  • 70
  • 146
8
votes
2 answers

Disable swipe in fragmentPagerAdapter? - android

I have a fragmentPagerAdapter with 3 fragments in it. How would I disable the swiping between the 3 fragments so the user only uses the tabview to go between fragments? private class ViewPagerAdapter extends FragmentPagerAdapter { …
8
votes
3 answers

Implement feature like iOS app closing vertical Swipe-to-Dismiss with ViewPager

I currently have Views lined up horizontally in a ViewPager and can cycle through them with a PagerAdapter. Currently, to perform the action that I would like to do on swipe, I have to do a double-tap on the View's page. I could post code, but it's…
8
votes
1 answer

Handling Orientation change with ViewPager + FragmentPagerAdapter

I'm having trouble handling screen orientation change with ViewPager and FragmentPagerAdapter. It works fine on application startup but the fragments inside the viewpager are not visible after orientation change (maybe lost). How do I fix this…
8
votes
4 answers

FragmentPagerAdapter getItem wrong position

I've got strange problem with FramentPageAdapter MainActivity.java @SuppressLint("ValidFragment") public class MainActivity extends FragmentActivity implements ActionBar.TabListener { ... ... @Override protected void…
user2536592
  • 171
  • 1
  • 6
1 2
3
40 41