Optimized List view with 1k object list

后端 未结 1 675
天涯浪人
天涯浪人 2021-01-06 08:31

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

相关标签:
1条回答
  • 2021-01-06 09:04

    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

    0 讨论(0)
提交回复
热议问题