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.
source share