ListView slowing down ViewPager swipe

陌路散爱 提交于 2020-01-02 07:37:24

问题


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?


回答1:


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.




回答2:


it's just because of list view scroll is conflict with view pager scroll..

if you want to know about this just set list view visibility gone don't remove code listView.setAdapter(adapter) then try view pager will slide properly.



来源:https://stackoverflow.com/questions/16817048/listview-slowing-down-viewpager-swipe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!