android - Why text is not formatted with Html.fromHTML? -


i'm trying display html code in text view. want display this:

code

i'm using page generate code: http://tohtml.com/java/

html:

<pre style='color:#000000;background:#ffffff;'><span style='color:#7f0055; font-weight:bold; '>public</span> <span style='color:#7f0055; font-weight:bold; '>class</span> mainactivity <span style='color:#7f0055; font-weight:bold; '>extends</span> activity {        <span style='color:#3f7f59; '>// called when activity created</span>      @override      <span style='color:#7f0055; font-weight:bold; '>protected</span> <span style='color:#7f0055; font-weight:bold; '>void</span> oncreate(bundle savedinstancestate)      {          <span style='color:#7f0055; font-weight:bold; '>super</span>.oncreate(savedinstancestate);          setcontentview(r.layout.main);      } } </pre> 

i'm tried this:

textview textview; // text view string data = loaddataasstring("/sdcard/code.html"); // function loads data file , returning string. textview.settext(html.fromhtml(data), textview.buffertype.spannable); 

and i'm getting result:

result

how can fix it?

i don't want use webview.

i'm using api 19 (android 4.4.4 - kitkat)

html.fromhtml() supports subset of html tags. this list bit out of date, give idea of can , cannot use. need alter html abide html elements fromhtml() can work with.

alternatively:


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -