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

Why fragment created in FragmentPagerAdapter is skipped sometimes when using getactivity() to find view?

I am using FragmentPagerAdapter to create multiple instances of fragment A. I tried 2 ways of finding views inside fragement A: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle…
0
votes
1 answer

Android ActionBar Tabs with FragmentPagerAdapter Class - saving the last tab selected when reloading activity

I am developing an app which is using ActionBar.NAVIGATION_MODE_TABS and a separate FragmentPagerAdapter class in order to swipe through 5 different screens. On these screens there are buttons you can press to load a new activity, and then go back…
0
votes
1 answer

how to refresh a listview inside a FragmentPagerAdapter and in one fragment adds data and the list is displayed in the another fragment

public class AllQuestions extends Fragment { ListView lstQuesions; QuestionsAdapter mAdapter; List questions; DataBaseHelper dbHelper; @Override public View onCreateView(LayoutInflater inflater, ViewGroup…
0
votes
0 answers

Show ProgressDialog unitl all fragments are loaded by FragmentPagerAdapter

I have a ViewPager containing 6 Fragments in my app. Each fragment displays only text information to the user. I have given the user the option of saving/sharing this information, but want to make sure all of the fragments are loaded before the…
0
votes
0 answers

ViewPager setOnPageChangeListener not working

Someone have idea where is problem? I can not get on page change listener to work. I need get actual position when page is changed but not working. I find a lot but problem is still here. Thx for time. public class SuperFragmentHome extends…
pavol.franek
  • 1,396
  • 3
  • 19
  • 42
0
votes
1 answer

How can I access localised strings from within a static FragmentPagerAdapter

I have followed official documentation on how to implement swipe views with TabStrip instead of Tabs in order to create a Fragment (FragmentMyAccount.class) that contains Nested Fragments (FragmentMyProfile.class and FragmentMyLibrary.class). These…
0
votes
1 answer

Android accessibility, focus on 3rd tab title when using fragments, focus should be on current tab title instead?

My application uses tabs with swipe navigation defined in developer.google.com where I am using the FragmentPagerAdapter. When trying to make sure my application is accessible, I came across the following problem: When the application is started,…
0
votes
1 answer

Android Code does not work / 2 questions

Hello can anybody tell me why this code give me error and crash my app? This happens only when 'reset((View) child);' is added at the end What I want to do is when I click a Button with onClick:reset, It will apply a kind of reset to only Images and…
Programmer
  • 15
  • 4
0
votes
1 answer

FragmentPagerAdapter getItem() method to start at a different position

I'm making a very simple app using the ViewPager. I would like to be able to start at a custom position when the getItem method is called. Below is my current code. @Override public Fragment getItem(int position) { switch (position) { …
0
votes
1 answer

The size of GridView keeps growing when PageAdapter (Android)

Solved( I just needed to change from FragmentPagerAdapter to FragmentStatePagerAdapter becuase the last one saves the states of a fragment that is not visible in the screen. So when you have to many fragments, which are not visible, the memory,…
0
votes
1 answer

FragmentStatePagerAdapter: Don' t load all Tabs at the beginning

In my Android app I use tabs with a FragmentStatePagerAdapter. I have many tabs, so it is a problem, that the FragmentStatePagerAdapter calls the onCreateView-method for all of them when the app starts. This is completely useless, because the method…
0
votes
1 answer

Avoid recreating same view when fragment pager changed

When I change fragment page recreate view in instantiateItem. How can I avoid this? public class ContactPagerAdapter extends PagerAdapter implements IconTabProvider { @Override public Object instantiateItem(ViewGroup container, int…
0
votes
1 answer

Xamarin\Android Development - How do I change Fragments by clicking on a listview item?

Here is the bit of code I have so far : namespace MyTestApp2 { [Activity(Label = "Simple ListView", MainLauncher = true, Icon = "@drawable/icon")] public class Activity1 : FragmentActivity { private CustomViewPager _viewPager; …
0
votes
1 answer

See next item in FragmentPagerAdapter

Is it possible to setup FragmentPagerAdapter in a way, that I can see full 1st item on a screen and a part of a second item on the right? So that user knows that she/he has to swipe to show the next one item? UPDATE: Like this: Fragment A doesn't…
Tom
  • 1,203
  • 3
  • 15
  • 35
0
votes
3 answers

Android viewpager notifyDataSetChanged causes IllegalStateException

Using cling library for upnp discovery. Whenever deviceDiscovered fires up, calling the below code to update device list and hence forth, calling notifyDataSetChanged of ViewPager public void deviceAdded(Registry registry, Device device) { …