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
53
votes
3 answers

ViewPager in TabFragment is not loading a second time

I'm trying to make an app that has a ViewPager in a Fragment that is part of a TabHost. Everything works out fine. I have my tabbar, I can switch tabs. When I switch to the tab with the ViewPager, all is shown correctly. However, as soon as I leave…
52
votes
5 answers

ViewPager preview layout in Android Studio

Is it possible to show a preview layout for ViewPager in AndroidStudio like in ListView/RecyclerView/etc.?
52
votes
9 answers

Android ViewPager Prev/Next Button

Okay, so I'm developing an Android app that utilises a ViewPager to display pages. Within each page, I have a set of buttons to use for navigating between pages (in addition to the swiping between pages). These buttons are for "first page",…
Eligos
  • 1,104
  • 1
  • 11
  • 26
50
votes
7 answers

Android - horizontal scrolling of multiple viewable items

EDIT: See my own answer for easy solution IMPORTANT: Bounty is offered for clear way to modify ViewPager to satisfy the scenario outlined below. Please do not offer HorizontalScrollView - I need full Fragment lifecycle scenario covered I need to…
Bostone
  • 36,858
  • 39
  • 167
  • 227
50
votes
11 answers

Get focused View from ViewPager

i use the ViewPager for switching views with left/right swipe. The ViewPager needs an Adapter, so I've built this one: public class ListViewPagerAdapter extends PagerAdapter { protected static final String TAG = "ListViewPagerAdapter"; protected…
Superroot
  • 661
  • 1
  • 6
  • 4
49
votes
6 answers

Saving Fragment state in ViewPager

I tried out the sample code from the API and it didn't really work so I implemented my own: FragmentPagerSupport public class FragmentPagerSupport extends FragmentActivity { static final int NUM_ITEMS = 10; MyAdapter mAdapter; ViewPager…
Android Noob
  • 501
  • 1
  • 5
  • 5
48
votes
5 answers

ViewPager - get a partial view of the next page

I am trying to achieve this in a ViewPager The first fragment (blue) is displayed and the beginning of the next fragment must be displayed as well, so the user understands he can swipe to switch views. The idea is scroll 20% of the screen…
znat
  • 13,144
  • 17
  • 71
  • 106
48
votes
4 answers

Kotlin - How to add OnPageChangeListener in ViewPager

I am new in kotlin, How can I add OnPageChangeListener in a ViewPager. viewPager?.addOnPageChangeListener // Now how can I add listener to it.
Rahul
  • 10,457
  • 4
  • 35
  • 55
48
votes
2 answers

How to fix 'android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5035)' error in android

I have layout with child (NOT as root) element RelativeLayout and then i create ViewPager and insert it as child of my Relative layout, so it's like +Relative Layout (root) | +-- Relative Layout (child) | +-- -- ViewPager For now moment - all…
Dmitry Nelepov
  • 7,246
  • 8
  • 53
  • 74
47
votes
10 answers

Changing ViewPager to enable infinite page scrolling

Jon Willis has posted on how to enable an infinite scrolling with his code. In there he said that he made some changes in the ViewPager class in the android support library. Which changes have been made and how is it possible to "recompile" the…
thehayro
  • 1,516
  • 2
  • 16
  • 28
47
votes
6 answers

Using Toolbar with Fragments

I am trying to create a viewpager that swipes through 3 different fragments each with a different toolbar. I have implemented the new toolbar in an activity before and got it to work however I am trying to get it to work with fragments Here is the…
47
votes
18 answers

Android ViewPager setCurrentItem not working after onResume

I've got this strange issue, ViewPager's setCurrentItem(position, false) works perfectly fine, then im switching to another activity, and after I'm back to the first activity, the ViewPager always ends up on the first item. Even though I've added…
Maciej Boguta
  • 1,354
  • 1
  • 12
  • 15
46
votes
9 answers

Can ViewPager have multiple views in per page?

After trying out the Gallery and Horizontal Scroll View, I found that the View Pager does what I need but with one minor thing missing. Can the View Pager have multiple views per page? I know that View Pager shows only 1 view/page per swipe. I was…
CLDev
  • 1,076
  • 3
  • 12
  • 20
46
votes
1 answer

Tools namespace attribute for showing layout in ViewPager in design time

The tools namespace allows for showing view properties in layout designer. For example using tools:listItem="@layout/{custom_layout} it is possible to show list with custom row layout in Android Studio designer. Question is: Is it possible to show…
46
votes
8 answers

View pager and fragment lifecycle

I have a ViewPager that loads three pages at a time. If I swipe from page 1 to page 2 then to 3, the first page(fragment) goes to onPause(). Then, if I swipe to the second page, 1st page comes to onResume() even though the page 1 is still not…
shreyas
  • 2,166
  • 3
  • 18
  • 30