Tag: android-viewpager

ViewPager not supporting layout_height = wrap_content

I’m building an android application with the following layout. It’s already known that layout_height=”wrap_content” doesn’t work for the ViewPager. My question is how to change it dynamically. The content of the ViewPager is inflated from two xml layouts, vp_statistics.xml and vp_campaigns.xml. here’s the xml for the ViewPager <LinearLayout android:id=”@+id/topcontent_wrapper” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_marginTop=”10dp” android:orientation=”vertical” > </LinearLayout> […]

“Activity has been destroyed” sometimes when populating viewpager with fragments

I am receiving crash reports with my viewpager v22 + FragmentPagerAdapter from all versions of android 4+ and 5+. The viewpager is in a fragment and the pager adapter is using the childFragmentManager It’s happening very rarely, to about 1/200 users. java.lang.IllegalStateException: Activity has been destroyed at android.support.v4.app.FragmentManagerImpl.void enqueueAction(java.lang.Runnable,boolean)(SourceFile:1397) at android.support.v4.app.BackStackRecord.int commitInternal(boolean)(SourceFile:636) at android.support.v4.app.BackStackRecord.int commitAllowingStateLoss()(SourceFile:619) […]

PagerTitleStrip do not show titles on first display page, the titles are only drawn after swiping to another page

Issue: After updating to appcompat-v7:23.0.0, both PagerTabStrip and PagerTitleStrip do not show titles on first display page (fig1), the titles are only drawn after swiping to another page (fig2). Library used : appcompat-v7 Version used: 23.0.0 Theme used: Theme.AppCompat.Light.DarkActionBar,Theme.AppCompat.Light.NoActionBar Devices/Android versions reproduced on: Nexus 5/ Android M Developer Preview 2 Steps to reproduce: Create a […]

Load only one Fragment in ViewPager

I have used ViewPager with Fragment.But it loads two pages at time.Is there any way to load only one page in viewpager ?

Android Using only ViewPager from Support Library

The new edition of my app has a minimum SDK of 14, so I thought that I could get rid of the support.v4 library that I’ve been using for the older version. However, it now looks like I might have to use ViewPager and thus am back to including the library. So can I just […]

How to limit ViewPager page changes to one per gesture

When you use setPageMargin to set a negative margin to your ViewPager the pages will become smaller than the full width of the ViewPager. Side effect of this is that user can then use one long gesture to change the active page more than once. Is there a way to prevent a single gesture changing […]

ViewPager in a ListView – how to lock the scrolling axis?

I have a ViewPager widget in every row of a ListView. This provides a shelf-like UI, so the user can scroll around searching for a shelf vertically, and then scroll horizontally amongst the contents of a shelf. This works. But the scrolling experience is terrible: if I start to drag a shelf’s ViewPager, scroll it […]

Android Lifecycle management of Fragments within ViewPager and FragmentPagerAdapter

I have been struggling to find out what the correct management of Fragments within a FragmentActivity with a ViewPager is. Before I go into details, a quick summary of the issue that I am facing is the following: I have a FragmentActivity with a ViewPager. The ViewPager uses a custom, yet very simple FragmentPagerAdapter. Each […]

Android ViewPager and ListViews

I’m relatively new to Android development and development overall. I’m having trouble grasping the syntax/process for ViewPager. I have several ListViews that I want to implement into a ViewPager. I’ve got the compatibility pack loaded and everything. But I haven’t seen any complete examples of how to do this. I learn best by looking at […]

Nested tabs with viewpager swiping in android?

I’ve implemented nested tabs with view pager with no problems, but my problem is on the swiping part, When I do the swiping action the main activity tabs will be switched, but I want the fragment to swipe instead. how can I achieve this? I’ve tried implement main tab with tab host and fragment tabhost […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.