Hesam
Hesam

Reputation: 53600

Adding HTML tags into text

In main page of my program I have some buttons such as Help. When user clicks it an activity appears and shows some guideline. It is full text and I need to change color of some words as I like. for bold and italic I don't have problem, easily I surround my words with . But I don't know what should I do to change color of some words.

Please tell me what should I do?

Upvotes: 1

Views: 565

Answers (3)

Paresh Mayani
Paresh Mayani

Reputation: 128428

I thought that you want to provide About us/Help file inside your android application, then you can perform as the following:

  1. Create a Help file in HTML
  2. Put that HTML Help file inside the assets folder that you found inside your Android project structure
  3. Now, you can load that HTML file inside the WebView using the below code:

webview.loadUrl("file:///android_asset/about_applicatio.html");

This way you can create a HTML file and thereby you can apply the color/javascript/bold/italic that you want inside the HTML file.

Upvotes: 1

RoToRa
RoToRa

Reputation: 38420

Use Html.fromHtml to create a Spanned text and assign it to the TextView.

http://developer.android.com/reference/android/text/Html.html

Upvotes: 1

GeekYouUp
GeekYouUp

Reputation: 1651

How about using a WebView instead of a TextView, then you can just update the HTML. It is definitely uses more resources, but may do what you need.

Upvotes: 1

Related Questions