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

how to implement refresh listview and bring new items in list if it reach end of list

I do not know how to implement refreshing listview and adding new items to list if it reach end of list in my parent fragment. I think I should explain my fragments structure first, because I found some tutorials and even libraries on githup but…
0
votes
1 answer

One Fragment inside ViewPager doesn't show up

I have a Tabbed Activity hosting a viewpager (auto-generated with eclipse wizard). I slightly modified just the auto generated FragmentPagerAdapter in order to instantiate a specific fragment on each tab. Initially i had 4 tab, 3 fragments for the…
0
votes
1 answer

Returning same fragment in adapter

I want to use the same fragment and replace contents with a reset function but when returning the same fragment for each tab I get following error : Can't change tag of fragment FragmentRank Here's my code : class pagerAdapter extends…
David
  • 840
  • 6
  • 17
  • 37
0
votes
1 answer

ViewPager only displays 2 out of 6 child Fragments using FragmentPagerAdapter

My app uses 2 identical ViewPagers that contain 6 images in each of their 6 Fragments. The leftViewPager's OnPageChangeListener swipe is used to control the rightViewPager. As I swipe through the 6 leftViewpager fragments the rightViewpager just…
user1272377
0
votes
1 answer

Loading data from asynctask to Fragments using FragmentPagerAdapter

I have a SlidingPagerAdapter with 4 fragments. Each fragment needs to be updated with data from server. I have used asynctask for this purpose. The Problem : We all know how ViewPager works. Is there as way where we can download data from server for…
0
votes
0 answers

Android - Setting TextView text in a callback to MainActivity not working as expected

I have a FragmentPagerAdapter that calls back to my MainActivity as follows: class MyFragmentPagerAdapter extends FragmentPagerAdapter { public void someMethod() { mMainActivity.setTextViewText("This is a test string"); } } In…
0
votes
2 answers

FragmentPagerAdapter didn't work with BaseActitvty

I got a simple FragmentPageAdapter in my Activity and it works fine. Now I would like to extend from a BaseActivity because I implemented a navigation drawer inside of the BaseActivity. Therefore I cannot extend of the FragmentActivity Class and I…
0
votes
1 answer

Setting custom PagerAdapter in Container Activity to destroy a ViewPagers fragments

So I have an activity with a ViewPager in it. I want it to destroy all the ViewPager's Fragments on button press in the activity and update the ViewPager's Fragments with new text/Views. I've written the code in the activity as below. …
0
votes
2 answers

How to access method in fragment from different class?

I have navigational drawer and fragment for each drawer item. Now Under each fragment we have created multiple fragments using FragmentPagerAdapter. I've 3 drawer items as Home, Group and Feedback. Under Home, there are 2 fragments i.e My Profile…
moDev
  • 5,248
  • 4
  • 33
  • 63
0
votes
1 answer

Performance for Android ViewPager and FragmentPagerAdapter with 3 Web Related Fragments

This is my first question. So please forgive me if my question is dummy quest. I search some questions and answer link and I think there is no 100% match for me. I'm trying to create an android application. It contain 4 fragment in one activity…
0
votes
0 answers

Android: Unable to display a fragment inside a viewpager where viewpager was inside a fragment

Having problem showing Fragment inside a ViewPager. I have a ViewPager which was hosted inside Fragment where this Fragment was inside the Activity. This ViewPager has a pagerTabStrip. Each page in ViewPager are Fragment of special usage. This is…
LittleFunny
  • 8,155
  • 15
  • 87
  • 198
0
votes
1 answer

How to access Views again after onCreateView in Fragment?

Actually I'm using Fragments with FragmentPagerAdapter, but I have the problem which is null when i tried to access views again in fragment. pageNum is null as well. I tried many ways to figure it out but it didn't work…
kimkevin
  • 2,202
  • 1
  • 26
  • 48
0
votes
1 answer

(Android)How to request the network data in the Fragment +Viewpager Mode

In the ViewPager+Fragment by FragmentPagerAdapter mode. I want to known How to load data for Internet. I want to implement: 1.Only select the current pager can to load data 2.Only performing the load data once to every pager I search the some…
0
votes
1 answer

Keeping PageView Fragment's View from disposal

I have an Android Application implementing a PageView with Tabs found here: https://github.com/sbpc/ajavacc The PageView loads its Fragments and displays everything properly; but occasionally the individual Fragments become disposed. Is there a way…
0
votes
2 answers

Cannot communicate with Fragment correctly after orientation change

I am having some trouble figuring out the proper way to communicate between fragments when using a FragmentPagerAdapter. For some context I have an Activity that uses the FragmentPagerAdapter to host two fragments. Fragment A has a button and when…
Donal Rafferty
  • 19,707
  • 39
  • 114
  • 191