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

causing a java.IllegalStateException error, No Activity, only when navigating to Fragment for the SECOND time

I am getting a very puzzling bug that I have no idea how to even begin working through. I have a simple app with one activity, the views are implemented with Fragments. One of the fragments has a ViewPager inside of it; so I decided I that I…
35
votes
4 answers

Getting Parent ViewPager View from inside Fragment

I am trying to access the parent viewpager from inside a fragment, but i have no idea how to do that. I need to switch the currentItem on the ViewPager after a onClick event inside the fragment. Any ideas? EDIT: I want access to the parent…
Manak Kapoor
  • 962
  • 3
  • 12
  • 21
35
votes
12 answers

IllegalStateException: is not currently in the FragmentManager

I know it sounds like a duplicate of FragmentStatePagerAdapter IllegalStateException: is not currently in the FragmentManager but his solution isn't relevant to my case. I'm getting the following crash very…
marmor
  • 27,641
  • 11
  • 107
  • 150
35
votes
3 answers

ViewPager FragmentPagerAdapter Nullpointer

I got this error by using the ViewPager in the Android Support package. from the Horizontal View Swiping with ViewPager Tutorial 06-19 13:07:25.950: E/AndroidRuntime(16382): FATAL EXCEPTION: main 06-19 13:07:25.950: E/AndroidRuntime(16382):…
passsy
  • 5,162
  • 4
  • 39
  • 65
34
votes
4 answers

ViewPager intercepts all x-axis onTouch events. How to disable?

Scope There is a viewpager of two fragments. One of those fragments has a layout witch listens to onTouch changes at X-axis. Problem Layout doesn't get almost all Action.Move events when touching and sliding along X-axis. It seems that viewpager has…
Oleksii Malovanyi
  • 6,780
  • 6
  • 24
  • 27
34
votes
1 answer

ViewPager with Navigation architecture components

Are there any uses for navigation with the viewpager? I can not find information about this and I do not understand how this can be done. I have an simple two fragments which is need to put inside viewpager and if its possible via navigation.
Roman
  • 803
  • 2
  • 10
  • 17
34
votes
10 answers

java.lang.Class java.lang.Object.getClass()' on a null object reference

I try to use viewPager with the tablayout but when i set adapter with the view pager i'm getting error "java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass() on a null object reference" i don't…
xyz rety
  • 671
  • 2
  • 11
  • 22
34
votes
1 answer

Using FragmentStatePagerAdapter WITHOUT support library

I would like to know is it possible to use the class FragmentStatePagerAdapter or its equivalent without the support library? I know how to use native fragments in place of those from the support library and many other classes have their similar…
34
votes
1 answer

3 android fragments in viewpager, how to keep them all alive?

I have a viewpager with at least 3 fragments. If the user inputs data into A, then B, then C and goes back to A that data is lost from A. I think I read somewhere that this has to do with memory management and since fragments only connect to or…
34
votes
15 answers

How to know viewpager is scroll left or right?

I am using ViewPager (support library). I want to know every time the ViewPager change the visible page, it is scrolling left or right. Please give me a solution. Any recommend is welcome also. Thanks
Nguyen Minh Binh
  • 23,891
  • 30
  • 115
  • 165
34
votes
5 answers

ClassNotFoundException when unmarshalling: android.support.v4.view.ViewPager$SavedState

I am seeing the following error in my Android crash reports: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v4.view.ViewPager$SavedState at android.os.Parcel.readParcelable(Parcel.java:1971) at…
user1509445
  • 351
  • 1
  • 3
  • 5
33
votes
8 answers

Action items from Viewpager initial fragment not being displayed

In the application I am developing I am using a ViewPager with fragments and each fragment constructs its own menu independently of all of the other fragments in the ViewPager. The issue is that sometimes the fragments that are initialised by the…
solarnz
  • 1,041
  • 1
  • 8
  • 23
33
votes
2 answers

remove fragment in viewPager2 use FragmentStateAdapter, but still display

I have a viewPager2 and FragmentStateAdapter, and there are Fragement1, 2,3 4, I am in fragment2, and want to remove fragment3, and display fragment4 after fragment2. The problem is it always show me fragment3(data), the debug shows the fragment3…
33
votes
9 answers

Viewpager fragments not shown after the first time

I have an activity with 3 fragments (A, B, C). Fragment A consists of a ViewPager with 2 ListFragments. The user can tap on an item in any of the listfragments and by doing so, goes to fragment B. In fragment A I do: @Override public void…
Ivan-Mark Debono
  • 15,500
  • 29
  • 132
  • 263
33
votes
6 answers

ViewPager in DialogFragment - IllegalStateException: Fragment does not have a view

What I want to achieve From a FragmentActivity show a dialog when clicking an Action Button in the Action Bar DialogFragment - A Dialog without title TabHost - Tabs at the top of the dialog ViewPager with FragmentPagerAdapter - Swipable, which…