Take the 2-minute tour ×

is it possible to format text in rows in Listview using html? I need to use font, b, i tags

I use this code to fill ListView

setListAdapter(new ArrayAdapter<String>(MyActivity.this,R.layout.resultlist,v));

where v is a vector array filled with strings


share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

No, but you can use the xml attributes to format the text in a TextView. For example, you can use the android:textStyle attribute to make the text bold, or italic. So if you want bold, you can do android:textStyle="bold" or if you want both bold and italic you can do android:textStyle="bold|italic". If you want different parts of your string formatted differently, checkout this SO Post.

share|improve this answer
Ok, so I can't do both on the same time if I understand... –  simPod Nov 4 '11 at 21:22
No, you can. Just do android:textStyle="bold|italics" It mentions that in the documentation. –  Kurtis Nusbaum Nov 4 '11 at 21:23
ah ok. I meant part of string is italic and part is bold –  simPod Nov 5 '11 at 14:14
Edited my answer to address this. –  Kurtis Nusbaum Nov 5 '11 at 19:12
add comment

Well, you can use:

Html.fromHtml("text with html");

But, I think it will slow down your ListView. Try to use android styling in your R.layout.resultlist xml layout. I'm sure you can find a way to avoid html formatting.

share|improve this answer
I can't add Spanned var to Vector –  simPod Nov 5 '11 at 14:14
add comment

Your Answer


