user1841247
user1841247

Reputation: 413

Are there any views to help me to show HTML text?

I have some text with html tags: a, br, b, and I need to show this text for user. Are there any views or ways to show this text for user keeping formatting? Thank you in advance

UPDATED:

There is the code:

    TextView view=new TextView(this);
    view.setText(Html.fromHtml("<a href='www.google.com'>link</a>"));
    view.setAutoLinkMask(Linkify.ALL);

When I click by link there are no actions. How can I fix it? I need to open a browser.

Upvotes: 0

Views: 53

Answers (1)

Vishesh Chandra
Vishesh Chandra

Reputation: 7071

If you have used some HTML tags in your string resource then you can use..

textView.setText(Html.fromHtml(R.string.your_string));

And set the tag android:autoLink="all" in your textview XML or

view.setMovementMethod(LinkMovementMethod.getInstance()); in java.

It will give you desired output...:)

Upvotes: 3

Related Questions