1

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

Thanks

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

No, you can. Just do android:textStyle="bold|italics" It mentions that in the documentation.
ah ok. I meant part of string is italic and part is bold
Edited my answer to address this.
1

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.

1 Comment

I can't add Spanned var to Vector

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.