Questions tagged [android-viewpager]

ViewPager.setcurrentItem( ) freezes ui

The ViewPager is a widget for Android that makes possible displaying different views (or fragments) side by side allowing the user to swipe between them. ViewPager was released as part of the Compatibility Package revision 3 and works with Android 1.6 upwards. ViewPager is a ViewGroup and works in a similar manner to AdapterViews (like ListView and Gallery).

Official Documentation

10802 questions
63
votes
4 answers

Fragment in ViewPager not restored after popBackStack

Problem A Fragment is not reattached to its hosting ViewPager after returning from another fragment. Situation One Activity hosting a Fragment whose layout holds a ViewPager (PageListFragment in the example below). The ViewPager is populated by a…
Paul
  • 3,077
  • 2
  • 18
  • 20
62
votes
10 answers

onPageSelected doesn't work for first page

My pager adapter ( extends PagerAdepter ) has a textview in it. And I update this textview with MainActivity's onPageSelected . Its update textview for position > 0 , but start page (position 0) doesn't update on startup. When I swipe forward then…
metemet06
  • 1,472
  • 4
  • 18
  • 30
61
votes
9 answers

Android Viewpager as Image Slide Gallery

I am using Jake's ViewPageIndicator and want to display Images like a swipe gallery. Any refernce link where i can get started. I have implemented the basic viewpager and now want to implement image viewpaper as below Is it possible to to achieve…
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
60
votes
8 answers

onClick on ViewPager not triggered

I set a click listener on a ViewPager, but the onClick event is never called. I guess the touch event detection of the ViewPager is interfering, but I can't see how to solve it... Anybody could help? Thanks mViewPager.setOnClickListener(new…
jul
  • 36,404
  • 64
  • 191
  • 318
59
votes
9 answers

Add / Delete pages to ViewPager dynamically

I would like to add or delete pages from my view pager dynamically. Is that possible?
Arnab Chakraborty
  • 7,442
  • 9
  • 46
  • 69
58
votes
5 answers

Navigating back to FragmentPagerAdapter -> fragments are empty

I have a Fragment (I'll call it pagerFragment) that is added to the backstack and is visible. It holds a viewPager with a FragmentPagerAdapter. The FragmentPagerAdapter holds (let's say) two fragments: A and B. First adding of the fragments works…
56
votes
4 answers

Starting Activity from Fragment causes NullPointerException

I'm stuck here with a problem starting an activity from a Button inside a Fragment. Here is my code: ViewPagerAdapter.java import java.util.List; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import…
Juke
  • 943
  • 1
  • 8
  • 14
56
votes
4 answers

Is it possible to have a ViewPager inside of a ScrollView?

I'm trying to use a ViewPager inside of a ScrollView, but the ViewPager does not appear. If I remove the ScrollView the ViewPager appears fine. I've created a simple test project with the following: main.xml layout:
C0deAttack
  • 24,419
  • 18
  • 73
  • 81
56
votes
3 answers

Fragment shared element transitions don't work with ViewPager

My app contains a view which consists of a ViewPager consisting of a handful of fragments. When you click on an item in one of these fragments, the expected behavior is for the shared element (in this case an image) to transition to the fragment…
JMRboosties
  • 15,500
  • 20
  • 76
  • 116
56
votes
6 answers

How to set a ViewPager inside a Fragment

I need to place a ViewPager inside of a fragment, but I have two fragments, Fragment 1 is my MENU, and Fragment 2 I want to use as a ViewPagerIndicator. But a fragment can't have another fragment... what do I need to do for that?
56
votes
4 answers

How to add a Fragment inside a ViewPager using Nested Fragment (Android 4.2)

I have a ViewPager with three Fragments, each one shows a List (or Grid). In the new Android API level 17 (Jelly Bean 4.2), one of the features is Nested Fragments. The new functionality description says: if you use ViewPager to create fragments…
56
votes
10 answers

ViewPager with fragments - onPause(), onResume()?

When using ViewPager with fragments, our onPause, onResume methods are not called when moving between tabs. Is there any way we can figure out in the fragment when we're being made visible or being hidden? Unfortunately I have logic in onResume,…
user291701
  • 38,411
  • 72
  • 187
  • 285
55
votes
8 answers

Multiple pages at the same time on a ViewPager

Is there a possibility to display two pages at the same time, when using a ViewPager? I'm not looking for an edge effect, but rather for two full pages at the same time.
Kirill Rakhman
  • 42,195
  • 18
  • 124
  • 148
55
votes
9 answers

Display fragment viewpager within a fragment

I have a fragment which contains a ViewPager. The ViewPager is associated with an adapter that contains a set of fragments. Upon loading the parent fragment, I am met with an IllegalStateException with the message: java.lang.IllegalStateException:…
55
votes
3 answers

Replace one Fragment with another in ViewPager

I'm having some problems when I try to replace one Fragment with another one in a ViewPager. Current situation I have a ViewPager with 3 pages, each one is a Fragment. In first page, I have a ListView inside a ListFragment ("FacturasFragment"). When…
Lyd
  • 2,106
  • 3
  • 26
  • 33