Optimized List view with 1k object list

六月ゝ 毕业季﹏ 提交于 2019-11-30 17:47:48

问题


I was wondering if there is any optimized way to create an adapter that holds more than 1k object in it. I have tried the following but still the results were not promising .

A.View holder pattern-It helped but when the object size increased it started have issues

B.Note: I could have used a paginated api which passes a defined number of objects but I annot have paginated Api in my scenerio.

C.My list do have images in it but I have taken care of that.Its not a problem now.

Let me know of any new ways to achieve a adapter that can have a large number of object list in it without any issues.


回答1:


As far as I know, I use some structure below

  • Use ViewHolder
  • Do not create new object if you not use
  • Optimizing Layout Hierarchies

https://developer.android.com/training/improving-layouts/optimizing-layout.html

  • Prevent Overdraw

https://developer.android.com/tools/performance/debug-gpu-overdraw/index.html

  • Load ImageView in ListView: I am using "Universal Image Loader" and enable mode: stop load image when scrolling

  • Optimize code in the getView(...) function of ListView Adapter: Try to make the code clear and short, restrictive use if{}else{}

  • If you have a problem with OutOfMemory, take a look at Java Reference https://www.rallydev.com/blog/engineering/java-references-strong-soft-weak-phantom

  • Try to use RecycleView, it much more powerful, flexible and a major enhancement over ListView https://stackoverflow.com/a/31199564/5381331



来源:https://stackoverflow.com/questions/33774215/optimized-list-view-with-1k-object-list

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