2

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?

3
  • Where did the raw data come from? Can you check it and paste it here Commented Nov 12, 2012 at 7:30
  • I don't think that fromHtml can handle css rules... Commented Nov 12, 2012 at 7:58
  • This is the text i have as string format ..now from this i need to get the body. <html><head/><body><html dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="MSHTML 8.00.7600.16385"> <style id="owaParaStyle">P { MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px } </style> </head> <body fPStyle="1" ocsi="0"> <div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hai</div> </body> </html> Commented Nov 12, 2012 at 8:15

2 Answers 2

4

Just Convert two times given example hope so help u

String des=Html.fromHtml(item.getVoucher_Description()).toString();
txtdes.setText(Html.fromHtml(des));
Sign up to request clarification or add additional context in comments.

Comments

2

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

4 Comments

but in my html file P tag is like follows. <style id="owaParaStyle">P { MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px } P is not as a tag.is this creating problem?
The list already says that , which tags are supported.. and that's it.. nothing more supported in that class.
If you still want to show some CSS and Styles then I think you will have to use webview instead of the edittext or textbox.
ok..thank u.but in my application i will get the body as html as above ,and i have menu options like "reply","replyall",when user clicks on reply/replyall i need to launch the mail client by putting body..but if i put body that p tag is creating problem.is there any alternative way to get the body from html page and pass to mail client?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.