Two small instances:
1, the service side returned with the HTML tag text, in the TextView display in the time, can correct the line.
2, need to display the download hyperlink, to text instead, hide:
The implementation results are as follows:
The code is as follows:
Package Com.android.study;import Android.app.activity;import Android.os.bundle;import android.text.Html;import Android.text.method.linkmovementmethod;import Android.widget.textview;public class FourthActivity extends Activity { Private TextView textview;private TextView texturl;private TextView texturl2;//HTML format wrap private static String msghtml = "1 , complete the task before the end of the task, and upload the data. <BR/>2, Mission content: 2 consecutive days to reach 10000 steps. <br/>3, you can see the progress of your task at the bottom of the progress display. ";//hyperlink private static string html =" My client: <a href= ' http://www.baidu.com ' > click Download </a> ";p rivate static string HTML2 = "My client,:";p rivate static String html22 = "<a href=\" "+" http://www.baidu.com "+" \ ">" + "click to download" + "</a> "; Charsequence charsequence = html.fromhtml (Html), @Overrideprotected void OnCreate (Bundle savedinstancestate) { Super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_texttest); init ();} private void Init () {///Textview.setautolinkmask (linkify.all); TextView = (TextView) Findviewbyid (R.id.textview); Texturl = (TExtview) Findviewbyid (r.id.texturl); textUrl2 = (TextView) Findviewbyid (R.ID.TEXTURL2);/** * HTML format Wrap */ Textview.settext (html.fromhtml (msghtml));/** * Hyperlink: Law one */texturl.settext (charsequence); Texturl.setmovementmethod ( Linkmovementmethod.getinstance ());/** * Hyperlink: Law two */texturl2.settext (HTML2); Texturl2.append (html.fromhtml (html22)); Texturl2.setmovementmethod (Linkmovementmethod.getinstance ());}}
The form of hyperlinks can both be achieved in this demo.
But the French one in my project code is not used successfully, replaced by law two can be.
There is a message to know the situation oh.
Display text containing HTML tags in Android textview