Search code examples
androidperformanceandroid-listviewandroid-viewpager

ListView slowing down ViewPager swipe


I have a ViewPager that contains ImageViews downloaded from the net and it slides just fine when my ListView (in another separate layout) is not initialized.

But the problems start when my ListView is created. The ViewPager still "slides" but only slides about 1/4 of the way, lags, then loads the next ImageView correctly.

All of the network and bitmap operations are done using AsyncTask. I've also used the RemoteImageCache API from Singly API which works pretty well.

Any ideas as to why ViewPager's swipe is lagging?


Solution

  • The slow down was caused by the ListView calling getView more than necessary (more than 3x per item in my list).

    According to this solution, the ListView's width and height must be given specific values and not wrap_content or else getView() will be called multiple times.