how to use view holder if custom listview row content are dynamic?
Asked Answered
T

1

6

i have create custom list view using base adapter to dynamic row content.row content are created programmatically (check box,text view) they are include in layout. problem to scrolling time they are very slow because not use view holder. how can i use view holder this type of custom list view? any solution or suggestion?

following this list..

enter image description here

Trifocal answered 3/11, 2014 at 6:27 Comment(3)
how many maximum dynamic view you need for each row? If that is fixed say 3 or 4 then you can create that in your adapter view and set the visibility as required.Navvy
it may be create number of view in row, initially we can't predict how many views will be created.Trifocal
use table layout and add number of rowIminourea
N
0

ViewHolder is use in a list view when same view is repeated. Say there are total 6 items visible at a time in your activity. Then using viewholder pattern 6+2=8 views will be inflated at a time. one extra at the top and one extra at the bottom to give smooth scrolling effect. Now suppose scroll up operation is performed, and item at 8th position is visible, item at 0th position will be recycled and appended at the end of the list as the 9th item. if the views are not same this recycling can not be performed. check https://www.youtube.com/watch?v=wDBM6wVEO70

For your problem you can assume there is 5 maximum value possible then you can create adapter view using 10 dynamic views inside and set visibility as required.

Another optionis use LinearLayout and add each row dynamically but this won't give much optimization.

Navvy answered 3/11, 2014 at 6:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.