3

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.

1
  • 1
    Html.fromHtml(<String>); will work Commented Jun 25, 2013 at 6:42

1 Answer 1

11

Use code like:

textview.setText(Html.fromHtml("YOUR HTML STRING"));

Hope it will help you.

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

2 Comments

Thx for the answer I cant accept it till the next 6mins it seems
Ya no problem. you can accept it later also. important thing is that you can now go ahead in your developement.

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.