开发者

How to use custom color for each textview in listview that extends SimpleAdapter in Android?

开发者 https://www.devze.com 2023-01-01 10:12 出处:网络
I have a listview with custom rows and that extends SimpleAdapter. Each row consist of two linear layouts : 1st having two textviews of which one is hidden in horizontal orientation, second having tw

I have a listview with custom rows and that extends SimpleAdapter. Each row consist of two linear layouts : 1st having two textviews of which one is hidden in horizontal orientation, second having two textviews in horizontal orientation. Now depending on the value in hidden textview , I want to setcolor for the remaining items for the row. To put it as simple: each listview item has some custom colors the value of which comes from the hidden field.

I have done this by overriding getview() for the simpleadapter and returning view for each, but this makes list very slow to render (and that I think is ob开发者_开发百科vious as so much of work for each view before showing it).

Can I do this in some more efficient way ? like making views and then add up to list instead of using xml layout maybe one solution OR any other ? Any help ? Thanks.


If you use convertView in your adapter, I would not expect you to have any particular speed issues. Creating and garbage collecting rows is expensive -- setting some colors on a set of TextViews is not. So, make sure you are using the convertView parameter to recycle your rows.

Here is a free excerpt from one of my books that covers row recycling.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号