How to use view holder if custom list list content is dynamic?

I have create a custom list using the base adapter for the dynamic line content.row the content is created programmatically (checkbox, text view), which they include in the layout. problem during scrolling, they are very slow because they do not use the view of the holder. how can i use the view holder this kind of custom list? any solution or suggestion?

following this list.

enter image description here

+6
source share
1 answer

ViewHolder used in a list view when the same view is repeated. Suppose your activity displays a total of 6 items. Then using the 6 + 2 = 8 views view template will be overpriced at a time. one extra at the top and one extra at the bottom to provide a smooth scroll effect. Now suppose that the scroll operation is performed, and the position at the 8th position is visible, the position at the 0th position will be processed and added at the end of the list as the 9th element. if the views do not match, this processing cannot be carried out. check out https://www.youtube.com/watch?v=wDBM6wVEO70

For your problem, you can assume that there are 5 maximum values ​​you can create using 10 dynamic views inside, and set the visibility as needed.

Another option uses LinearLayout and dynamically adds each line, but this will not give much optimization.

0
source

Source: https://habr.com/ru/post/977629/


All Articles