I have a ListView that has a TextView and in each TextView several items, each with a brief description. In order to apply different styles to the items and description I am using multiples span objects: ClickableSpan, ForegroundColorSpan, BackgroundColorSpan, AbsoluteSizeSpan and StyleSpan.
On average the ListView has 10 TextViews, and each TextView has 10 pairs of item/description and each pair uses around 6 SpanObjects so a total of ~600 SpanObjects per ListView. And when the user clicks one of the items the ListView is cleared and redraw again generating another set of 600 SpanObjects.
So I am wondering if it would be a better idea to create one TextView for each item and each description and format it through XML rather than styling the TextViews with span, this way there would be around 200 TextViews and no SpanObjects.
As a note, I did not start with this approach because the hierarchy tree of views was going to be more complex and TextViews are more expensive to create that the SpanObjects but now that I see the number of SpanObjects I am creating I am not sure what is better. I am also thinking to start writing a recycling mechanism but not sure if it is worth or this should not be a problem for Android GC.