2013-02-14 61 views
5

我有HTML字符串,並在此字符串SpannableString,並把所有的TextView和問題SpannableString,他不是在Html.fromhtml()顯示,我怎麼能顯示SpannableStringHtml.fromHtml這可能嗎?的Android html.fromhtml + spannablestring

for(int index = 0; index < l.length; index++){ // have3d() return SpannableString 
      x += "<font color=\"green\">"+ have3d(title[index])+ " </font> <br />"+l[index] + "<br/><br/>"; 
      if(index == l.length-1){ 
       x += "<font color=\"green\">"+title[index]+" </font> <br />"+l[index]+ "<br/>"; 
      } 
     } 
mcinema.setText(Html.fromHtml(x)); 

回答

11

Html.fromHtml返回Spanned,就可以轉換爲SpannableString這樣:

SpannableString text = new SpannableString(Html.fromHtml(x)); 

,然後通過調用設置:

mcinema.setText(text, BufferType.SPANNABLE);