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
45
votes
8 answers

Cannot convert from android.support.v4.app.Fragment to android.app.Fragment

I'm doing my first Android app, and wanted to get straight into the ICS API. I have so far created an app using an ActionBar, with swipeable tabs using Viewpager and Fragments. I do however experience some errors that I keep returning to. Depending…
44
votes
9 answers

FragmentPagerAdapter is not removing items (Fragments) correctly

I have implemented the FragmentPagerAdapter and and using a List to hold all fragments for my ViewPager to display. On addItem() I simply add an instantiated Fragment and then call notifyDataSetChanged(). I am not sure if this is necessary…
Maurycy
  • 3,911
  • 8
  • 36
  • 44
44
votes
9 answers

ViewPager inside ViewPager

I would like to create a ViewPager (with three items) where each of its view is another ViewPager (with two items). User then swipe items like this: ViewPager1[0] ViewPager2[0] ViewPager1[0] ViewPager2[1] ViewPager1[1] ViewPager2[0] ViewPager1[1]…
44
votes
3 answers

ViewPager set current page programmatically

I wrote a custom ViewPager to disable Swipe Scroll, but I want to swipe programmatically. I have three Tab in my view pager, but when I call viewPager.setCurrentItem(viewPager.getCurrentItem()+1) on the first Fragment, it moves to the third Fragment…
Tonespy
  • 3,257
  • 7
  • 26
  • 52
44
votes
7 answers

Android how to stop refreshing Fragments on tab change

I have the following code : MainActivity.java package com.erc.library; import java.io.BufferedInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import…
44
votes
6 answers

ViewPager call setUserVisibleHint after first Fragment is loaded

In my application, I have a ViewPager which holds many swipeable Tabs with Fragments inside. I use the setUserVisibleHint method to detect when a Fragment comes to the screen. This works great when the user swipes between tabs but it does not work…
Cilenco
  • 6,951
  • 17
  • 72
  • 152
44
votes
5 answers

ViewPager animation fade in/out instead of slide

I got the FragmentBasics example from here. Is there a way make the ViewPager animation simply fade in and out when I swipe instead of sliding left and right? I've been trying some stuff with PageTransformer, but no success, I can still see it…
KKO
  • 1,913
  • 3
  • 27
  • 35
44
votes
9 answers

How can make my ViewPager load only one page at a time ie setOffscreenPageLimit(0);

I understand the lowest number I can give setOffscreenPageLimit(int) is 1. but I need to load one page at a time because memory problems. Am i going to have to use the old style tabhost etc? or is there a way/hack I can make my viewPager load one…
124697
  • 22,097
  • 68
  • 188
  • 315
44
votes
5 answers

Android: velocity-based ViewPager scrolling

The way the ViewPager scrolls right now is by one item per gesture. It treats flinging gesture the same way no matter if it's full screen fast fling or slow dragging; at the end page advances one step only. Is there any projects perhaps or examples…
Bostone
  • 36,858
  • 39
  • 167
  • 227
43
votes
5 answers

Dynamically add and remove tabs in TabLayout(material design) android

I have a TabLayout and inside that I have ViewPager. I need to dynamically add and remove tab in tablayout(material design). I can able to add the tabs dynamically but while removing the tab, tab is removing correctly. But viewpager last item is…
41
votes
8 answers

CoordinatorLayout inside another CoordinatorLayout

CorodinatorLayout inside another CoordinatorLayout such that scrolling the child-view should also scroll the Parent CoordinatorLayout. I have a coordinatorLayout with ViewPager that contains different Fragment such that on Scroll will hide the…
41
votes
10 answers

IllegalStateException: The application's PagerAdapter changed the adapter's content without calling PagerAdapter#notifyDataSetChanged

I'm using the ViewPager example with ActionBar tabs taken from the Android documentation here. Unfortunately, as soon as I call the addTab method, the application crashes with the following exception: IllegalStateException: The application's…
41
votes
7 answers

ViewPager OnItemClickListener

I'm new to Viewpager, and after reading http://developer.android.com/reference/android/support/v4/view/ViewPager.html from google, I can't seem to find anything related on viewPager.setOnItemClickListener(new OnItemClickListener() { Do we have other…
KC Chai
  • 1,607
  • 9
  • 30
  • 59
40
votes
5 answers

ViewPager show next and before item preview on screen

I want to show viewpager next and before page preview in screen. Before and next page show deep in screen and slide next page with deep animation. You can look this image How can i do it?
msevgi
  • 4,828
  • 2
  • 24
  • 30
40
votes
1 answer

Testing ViewPager with Espresso. How perfom action to a button of an Item?

I have a ViewPager whith items containing only a picture and a button. I can't successfully interact with the UI of an item (Page) because, except the displayed picture, there is nothing to differentiate (from UI point of view) all items of the…
damson
  • 2,635
  • 3
  • 21
  • 29