Reputation: 593
I have been able to use html tags in the string ie, to set textview from resource like :
<resources>
<string name="somestring">
<B>Title</B> <I>Italic</I><BR/>
Content
</string>
</resources>
This works fine when the text is in resource and I set it to my textView.
Now, I want to programmatically set a string I get from server at runtime to the textView. Therefore I can't define the string in resource folder.
I tried the following
textView.setText("<B>Bold</B><I>Italic</I>");
but this doesnt work. Any help would be appreciated.
Upvotes: 3
Views: 3951
Reputation: 3080
Use code like:
textview.setText(Html.fromHtml("YOUR HTML STRING"));
Hope it will help you.
Upvotes: 11