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

How to add a Fragment to List

I created the following packages: HomePage -> HomeActivity.class,HomeFragment.class,SectionsPageAdapter.class Friends -> Friends.class Messages -> Messages.class SectionsPageAdapter extends FragmentPagerAdapter to manage Fragments, The code…
-1
votes
1 answer

How can a fragment not be reset when not on screen?

I'm developing an android application (for Marshmallow at least) using Android Studio on Windows 10. My app was created using the tabbedActivity template provided by Android Studio. Which means it contains a mainActivity containing a…
-1
votes
1 answer

Clickable links with PagerAdapter

I have some text displayed with FragmentPagerAdapter. This text contains some links which I need to have clickable. There is a solution using OnTouchEvent with a View, but how do I get the coordinates then? Or is there a better solution for…
Bord81
  • 525
  • 2
  • 8
  • 23
-1
votes
1 answer

I would like to develop Calendar which swipe able and need to show previous current and next month names in Tabs

Can you please suggest me how to develop a calendar app using viewpager and Tablayout. Where there will be three tabs to show previous, current, next month names..!! i did not start developing, i'm fresher to android so need to know to start this
-1
votes
1 answer

Implementing a ViewPager with Fragments, only one page is changing among all the pages in the ViewPager

I have been trying to implement a ViewPager with different fragments. And the problem is when i run the app, in the ViewPager, out of all the pages, only one page is visible and that page only gets changed when I slide over to the other pages in the…
-1
votes
1 answer

Difficulty with FragmentPagerAdapter

Preface: I'm very new to Android. I've looked around, read numerous tutorials and I'm still not grasping the concept here. I will apologize in advance if it is something simple. I have an activity that is implementing a FragmentPagerAdapter using…
-1
votes
2 answers

IllegalStateException: adapter's content without calling PagerAdapter#notifyDataSetChanged

I did search all the question related to this but could not find any solution here is my code. private Toolbar toolbar; private TabLayout tabLayout; private ViewPager viewPager; MyFragmentPagerAdapter pagerAdapter; ArrayList titles = new…
-1
votes
1 answer

Android ViewPager with Fragments - Touch events reach the previous fragment in Pager

I have a ViewPager of 3 fragments. When every I switch to my third fragment, touching it in places where the previous fragment had touch events is activating those events. Example: When I set the current item to 2 (Third fragment, Menu) and I click…
-1
votes
1 answer

ViewPager with FragmentPageAdater not working properly?

I have an Activity which extends ActionBarActivity and activity has following code in xml.
-1
votes
1 answer

Why ProgressBar becomes null when i call a Fragment's method from FragmentActivity?

I am using dispatchKeyEvent in my FragmentActivity and calling one of my fragments method. Following is code I am using for my FragmentActivity: public class ViewPagerFragment extends FragmentActivity{ MyAdapter mAdapter; ViewPager mPager; …
-1
votes
1 answer

Intent in AsyncTask for FragmentPagerAdapter

I have implemented a FragmentPagerAdapter of 4-lashes, and in each of them I load a fragment with a different view. In one of them, pressing an image executed a AsyncTask to obtain a series of data from a server and loads a new class through an…
KryNaC
  • 379
  • 4
  • 21
-2
votes
1 answer

I am have an Activity and bind two fragment using FragmentPagerAdapter

I have an Activity and bind two fragment using FragmentPagerAdapter, we have one String variable that have null values.I'm calling a method and pass the results in string, when we return from second fragment string values show a null, but when we…
-2
votes
1 answer

FragmetPagerAdapter first Tab showing wrong data

I'm trying to implement a FragmentPagerAdapter with dynamically created Tabs based on a Cursor that retrieves distinct values from an SQLite DB column. Then the ListFragment loads data based on a 2nd Cursor that selects data with a filter based on…
Joost
  • 82
  • 1
  • 9
-2
votes
1 answer

Init fragments for FragmentPagerAdapter when its parent visibility is set to GONE/INVISIBLE

When a fragments visibility containing a ViewPager is set to GONE or INVISIBLE, the fragments in the ViewPager aren't initialized. They only seem to be initialized if the parent fragment is visible. How can I get around this problem? All I want to…
user3357751
  • 101
  • 1
  • 10
-2
votes
1 answer

ViewPager (with pagetransformer animation) crashes while rotating screen

i just noticed if i use DepthPageTransformer() animation,app crashes while rotating screen portrait to landscape. Crash reason is NullPointerException:(but it's not about my array list or object.already added a reason.And already added debugging…
erginduran
  • 1,678
  • 5
  • 28
  • 51
1 2 3
40
41