开发者

How to display an html code on android application [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.
<html>
<head>
<title>Company Name -MyCompany Inc.</title>
</head>
<body><strong >My<font color ='ORANGE'>Company </font>Inc.</strong>
<br><font face='Times New Roman' size='2' color ='#0000A0'><b>CONTACT DETAILS</b> </font></br>Address
<br> 
<br> Phone:</开发者_Python百科font> 1-xxx-xxx-xxxx x100 
<br>Fax:</font> 1-xxx-xxx-xxxx
<br><font color ='#0000A0'><b>Website:</b></font>
www.mycompany.com<br><font color ='BLACK' size ='1' face= 'calibri' ><b>Version : 1.008   </b></font> <br><font color ='BLACK' size ='1' face= 'calibri' ><b> Copyright @2011 myCompany Inc., ALL Rights Reserved</b></font><br></body></html>

I want to display this code in textview. Can anybody help me?


Some HTML formatting can be displayed if you use TextView.setText(Html.fromHtml(strMyHtmlString));

If that doesn't do everything you want, I would use a WebView


Take a look at the documentation for the HTML element in Android:

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

Specifically, you're going to want to look at the fromHhml() method.


yourTextView.setText(Html.fromHtml("YourHTML"));


Best of my knowledge you can not display full html in Textview. WebView will solve your issue but If you want to make link enable for email, phone numnber, then It is possible.

 Linkify.addLinks(text, Linkify.PHONE_NUMBERS | Linkify.WEB_URLS);

    // Recognize all of the default link text patterns 
    Linkify.addLinks(text, Linkify.ALL);

    // Disable all default link detection
    Linkify.addLinks(text, 0);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜