Questions tagged [android-pageradapter]

A base class providing the Adapter used to populate pages inside of a ViewPager.

Base class providing the Adapter used to populate pages inside of a ViewPager. You will most likely want to use a more specific implementation of this, such as FragmentPagerAdapter or FragmentStatePagerAdapter.

More information can be found in the documentation of the class.

Tag Usage:

431 questions
29
votes
3 answers

How do I implement view recycling mechanism for PagerAdapter?

I have a pager adapter that suppose to inflate a complex view representing a calendar. It takes around ~350 ms to inflate each year of the calendar. To improve performance I would like to implement the same mechanism that exists in the ListView…
Mortalus
  • 10,046
  • 9
  • 60
  • 108
25
votes
1 answer

Destroy item from the ViewPager's adapter after screen orientation changed

So I'm having a problem with destroying (removing) one page from the ViewPager after the screen orientation changed. I'll try to describe the problem in the following lines. I'm using the FragmentStatePagerAdapter for the adapter of the ViewPager…
25
votes
5 answers

Android: FragmentPagerAdapter: getItem method called twice on First time

In My application, I have used the ViewPager. Like, (say main.xml)
Sridhar
  • 2,108
  • 10
  • 42
  • 79
20
votes
4 answers

FragmentPagerAdapter - how to detect a swipe or a tab click when user goes to a new tab?

I have a MainActivity that has three fragments in a FragmentPagerAdapter as below. How can I find out when an user goes from 1st fragment to second or from second to third, either with swiping or with a click on the tab? I saw that the getItem()…
20
votes
4 answers

ViewPager not showing anything

I am create view pager with custom view pager adapter but when i run the project i can not see anything public class CustomAdapter extends PagerAdapter { private List newsObjects; private Activity mActivity; …
Kamal Upasena
  • 1,259
  • 3
  • 13
  • 38
18
votes
6 answers

PagerAdapter.notifyDataSetChanged does not refresh fragments

My Activity contains a ViewPager and it's custom Adapter which extends FragmentStatePagerAdapter. ViewPager contains 3 fragments Code to remove Fragments from the ViewPager MainActivity public void deleteElement(){ final int currentItem =…
royB
  • 11,685
  • 14
  • 48
  • 77
17
votes
3 answers

ViewPager PagerObserver was not registered

My application closes when i turn off my screen and turn it back on. Logcat tells me that the cause of this error is pointing to java line 60 in my CourseFragment.class which extends Fragment. mViewPager.setAdapter(infoTechPageAdapter); I am…
17
votes
3 answers

Android ViewPager scrolling issue with only one item when using getPageWidth from PagerAdapter

I have a ViewPager with a custom PagerAdapter that overwrites the method getPageWidth to return 0.3f, so I can show multiple pages in the screen, as suggested in the following…
16
votes
6 answers

ViewPager - onCreateView is not always called

I have a ViewPager with 10 pages. When I start the last (10th) page onCreateView() method of my fragment is called. When I swipe to the 9th page onCreateView() is called also. But when I back to the 10th page onCreateView() isn't called. What's…
14
votes
1 answer

Could not filter a PagedList?

I've implemented a recyclerview with paging with the Android's Paging Library (https://developer.android.com/topic/libraries/architecture/paging.html). It works fine on fetching data and retrieve subsequent pages. However, how to filter the…
14
votes
1 answer

Why is getCount called so many times in PagerAdapter?

I noticed today that the PagerAdapter gets called a large amount times. I counted 393 when scrolling pages slowly. I saw this question but it didn't really provide me with a good answer. Is this normal behaviour If so, why is it that the getCount…
Qw4z1
  • 2,949
  • 1
  • 22
  • 35
13
votes
6 answers

Android View Pager Adapter shows empty screen

I am implementing Pager Adapter in a Fragment. When I load the screen First time, it works fine. If i switch to other fragment and goes to previous fragment again the it shows empty screen. If I swipe between different tap and move to first tab…
user3789702
  • 191
  • 1
  • 2
  • 12
13
votes
2 answers

Some confusion on the method instantiateItem(ViewGroup container, int position) of PagerAdapter

public Object instantiateItem(ViewGroup container, int position) { ImageView view = new ImageView(); container.addView(view); return view; } I read some example code of PagerAdapter, and they all write the addview method. This…
Hexor
  • 475
  • 1
  • 7
  • 19
12
votes
2 answers

Deprecated PagerAdapter.instantiateItem() method

I'm curious as to why instantiateItem was deprecated in favor of it's newer version. The change is that it now receives ViewGroup in stead of a more general View. Deprecated method public Object instantiateItem (View container, int position) New…
Juan Andrés Diana
  • 2,185
  • 3
  • 22
  • 36
11
votes
2 answers

Correctly implementing PagerAdapter in Android

I have problems with implementation of my custom PagerAdapter and using it with a ViewPager. This sample PagerAdapter has 10 items, every item is a button with it's index as text. When I run my program, I see a button with text '1' insted of '0'.…
oriskop
  • 131
  • 1
  • 1
  • 5
1
2 3
28 29