简体   繁体   中英

image is display on android textview using html.fromHtml

This is my xml string content:

<style>
  img {padding:0 10px 10px 0; width:99% !important;}
  p,div,ul,ol,em,a,span,u,strong,strike,h1,h2,h3,h4,h5,h6
  {font-family: verdana;font-size: 14px;color: #fff;}
  html,body{background:#414042;}
  a{ color:#3400f3;}p{width:100%;}
</style>

<p> 
    <img alt="Ajay Devgn" pimcore_disable_thumbnail="true" pimcore_id="6813" 
    pimcore_type="asset" src="http://dev2.mercuryminds.com/bolly/feb2013/
    bolly---ajay-devgn-on-a-satyagraha/kangna-and-kareena.jpg" style="width: 500px; 
    height: 370px; float: left;" />
</p> 

Here the image is display on android textview.

But the image is not displaying....whats wrong in my code ??? How can i display the images on textview ...pls give me solution ...

String fullcontent = in.getStringExtra("Content");
      content = fullcontent.substring(1);       
      content = (TextView) findViewById(R.id.title1);
      content.setText(Html.fromHtml(full_content));
public static Spanned fromHtml (String source)

Added in API level 1 Returns displayable styled text from the provided HTML string. Any tags in the HTML will display as a generic replacement image which your program can then go through and replace with real images.

This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.

so insted of that use

public static Spanned fromHtml (String source, Html.ImageGetter imageGetter, Html.TagHandler tagHandler)

Returns displayable styled text from the provided HTML string. Any tags in the HTML will use the specified ImageGetter to request a representation of the image (use null if you don't want this) and the specified TagHandler to handle unknown tags (specify null if you don't want this).

This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.

for more detail check this answer ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM