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
40
votes
13 answers

How can I detect a click in an onTouch listener?

I have a ViewPager inside a ScrollView. I need to be able to scroll horizontally as well as vertically. In order to achieve this had to disable the vertical scrolling whenever my ViewPager is touched…
124697
  • 22,097
  • 68
  • 188
  • 315
39
votes
9 answers

TabLayout with viewpager not smooth scrolling

Edit I have followed these tutorials to fix this…
39
votes
6 answers

How to add margin between EditText and Soft Keyboard?

I want to add 10dp margin between EditText and Soft Keyboard. Here is my XML:
39
votes
4 answers

Differentiating between user scroll and programatic page change in ViewPager

I have a android.support.v4.view.ViewPager in my application and I would like to differentiate between a programmatically-initiated smooth scroll and a user-initiated touch scroll. I've had a look at ViewPager.OnPageChangeListener and I believe…
Kent Hawkings
  • 2,793
  • 2
  • 25
  • 30
39
votes
1 answer

ViewPager + FragmentPagerAdapter inside a DialogFragment gets "IllegalArgumentException:No view found..."

I am trying to show a FragmentDialog ( created and shown as a dialog NOT added as content in a view hierarchy) where there is a ViewPager whose content is given by a FragmentPagerAdapter (provides Fragments consisting of an image). The code works…
38
votes
3 answers

Swipe one item at a time Recyclerview

I tried adding on Scroll listener for recycler view and made some logic but i am not able to swipe one item at a time. I did some search on internet but i got some third party library which has custom recycler view. Can we implement one item swipe…
38
votes
5 answers

layout_margin in CardView is not working properly

I am playing with the new CardView, but the margins don't seem to be applying.
Eric Cochran
  • 8,414
  • 5
  • 50
  • 91
38
votes
2 answers

How to load fragment data only when its tab is clicked in PagerSlidingTabStrip

I am using PagerSlidingTabStrip in my project and am showing data in fragments. Its a great library which works great. Each Fragment consists of a scholar's lectures which are loaded from a web service. The code to access the web service is in…
Aamir
  • 1,747
  • 5
  • 26
  • 50
38
votes
5 answers

FragmentPagerAdapter getItem is not being triggered

Currently, with a FragmentActivity, I toggle among 2 type of Fragments using the following code. private void toggle() { Fragment oldFragment = getSupportFragmentManager().findFragmentById(R.id.content); Fragment fragment = null; if…
38
votes
4 answers

Why it is not possible to use ViewPager within a Fragment? It actually is

There are information that it is impossible to use ViewPager within a Fragment in many sources like "The Busy Coders Guide for Android Developers" by Mark Murphy, or posts like this on SO. I'm confused because I don't have such a problem and I…
Eugene
  • 59,186
  • 91
  • 226
  • 333
35
votes
2 answers

Android ViewPager with previous and next pages visible?

I am currently building a horizontal gallery of videos. I'd like to make something like that with only one video centered and part of previous and next videos: I first opted for a Gallery but its limitations made me look for something else. I'd…
Romain Piel
  • 11,017
  • 15
  • 71
  • 106
35
votes
1 answer

Android Error : IPerf::tryGetService failed

I am developing a simple Android app. In my app I implement a toolbar and an actionbar with a ViewPager for doing swipe between fragments, I am using a RecyclerView to fill a list of movie and everything goes fine. The app doesn't crash but in the…
35
votes
5 answers

Dynamic height viewpager

I'm trying to create a custom viewpager inside custom scroll viewthat dynamically wraps the current child's height. package com.example.vihaan.dynamicviewpager; import android.content.Context; import android.util.AttributeSet; import…
35
votes
4 answers

How to disable ViewPager from swiping in one direction

I want to allow the user swipe in a ViewPager only from right to left. So once he passed a page he can't come back to it. How can this be done? I tried this solution: public class CustomViewPager extends ViewPager { float lastX = 0; boolean…
Emil Adz
  • 40,709
  • 36
  • 140
  • 187
35
votes
6 answers

How to destroy old fragments in FragmentStatePagerAdapter

I want to implement this: I use a ViewPager with a FragmentStatePagerAdapter. I started with the example from this page: http://developer.android.com/reference/android/support/v4/app/FragmentStatePagerAdapter.html This is my ViewPager adapter: …
vovahost
  • 34,185
  • 17
  • 113
  • 116