Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 569
Ron Avatar asked Jan 27 '26 04:01

Ron


1 Answers

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.

like image 67
Ron Avatar answered Jan 28 '26 19:01

Ron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!