简体   繁体   中英

Html.fromHtml(string ) is not parsing P tag in android

I need to get the body from the following file. When I use Html.fromHtml(string) , then I am getting the body + some unformatted data as

P {
    MARGIN-TOP: 0px;
    MARGIN-BOTTOM: 0px 
}

<P/> tag will not work with Html.fromHtml(string ) . Why?

Just Convert two times given example hope so help u

String des=Html.fromHtml(item.getVoucher_Description()).toString();
txtdes.setText(Html.fromHtml(des));

Here commonsware says that P tag is supported. Supported TAGS by HTML.fromHtml() - Blog

For example you should use it in a string like this

<string name="htmlFormattedText">
          <![CDATA[
          <p>Text with markup for <strong>bold</strong>
          and <em>italic</em> text.</p>
          <p>There is also support for a
          <tt>teletype-style</tt> font.
          But no use for the <code>code</code>
          tag!</p>
          ]]></string>

Source From Here

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