Viewpager+FragmentpagerAdapet+Fragments+Listview = insanely slow app

I have a viewpager in my layout , that viewpager holds a set of 10 fragments . Each fragment has a list view , which is asynchronously populated . I m currently using FragmentPagerAdapter as adapter for the viewpager and the API calls to populate the list view is done in onCreateView of each fragment . The swipe is insanely slow and app closes itself because of the memory issues .

How to achieve smooth and responsive (viewpager+listview) like Google Play does ?
Smooth swiping + good cache of list items ?

  • How to do HTTP authentication in android?
  • How to use OpenCL on Android?
  • Android Content Provider database leak issue
  • List assets in a subdirectory using AssetManager.list
  • Android Spinner databind using array list
  • How to set the button background image through code
  • enter image description here

    Related posts:

    How can I set onClickListener on ArrayAdapter?
    Android 6 getAccountName() Missing android.permission.GET_ACCOUNTS
    setStorageEncryption produces no effect
    Navigating back to FragmentPagerAdapter -> fragments are empty
    Android, disable the swiping to interact with SlidingPaneLayout
    How add an Application Pre-loader/Startup screen/Splash Screen to My PhoneGap Android App
  • Nested parcelable object not reading
  • How to build a part of Android AOSP?
  • Getting “Unknown Application ABI” when trying to debug some C code in my Android app
  • Stuck with @SuppressLint(“NewApi”) (
  • Android & iOS: How to develop for both?
  • public or private, does it really matter with Android variables
  • One Solution collect form web for “Viewpager+FragmentpagerAdapet+Fragments+Listview = insanely slow app”

    There are many ways to improve the performance of a ViewPager integrated with a ListView.

    First, change the PagerAdapter from FragmentPagerAdapter to FragmentStatePagerAdapter. The difference is that you load 10 pages within the pager. And if you went through all the manager will only put the pages in onStop() therefore it will reserve space. However using FragmentStatePagerAdapter will destroy these pages but will save their instance using the onSaveInstanceState method. So when you get back it won’t take much time to load and you will be saving memory.

    Usually FragmentPagerAdapter is used with 3 pages or less.

    The second way to improve performance (but it drains the battery faster) is adding this line to your AndroidManifest.xml under your application tag:


    The third way is detecting the swipe gesture. You can do this by implementing onPageChangeListener then in the implemented method onPageScrollStateChanged you check if the page is Idle then add the ListView. Otherwise, stop the use of ListView and scroll to the next page. Here is a better explanation of this point.

    Hope some of these points can help you out to achieve better performance.

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