I have to format the text as table in the email body of email client. But i read somewhere android doesn't
support
< table> tag. Is any other alternative is there for doing this? I tried a lot but still i am not finding any good solution. Please can anyone help me.
code
String body = "< table border="+"1"+">< tr>< td>row 1, cell 1< /td>"+ "< td>row 1, cell 2"+ "< /tr>"+ "< tr>"+ "< td>row 2, cell 1< /td>"+ "< td>row 2, cell 2< /td>"+ "< /tr>"+ "< /table>";
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText());
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body).toString());
startActivity(Intent.createChooser(emailIntent, "Email:"));
Actual Output is this
But I Expected output is similar to following:
Try this:
Ok as the above isn't working try this:
http://www.edumobile.org/android/android-programming-tutorials/how-to-send-an-email/
The code from your example does work fine for anything without table. I thought it could be forced, but I've hit a wall here.
Perhaps this can work around it: Display HTML Table in webview
Or perhaps you can force something like this through in your activity (adjust to suit your purpose):
WebView webview = new WebView(this); setContentView(webview); String yourHtml = "<html><body><table>...</table></body></html>"; webview.loadData(yourHtml , "text/html", "utf-8");
来源:https://stackoverflow.com/questions/12154790/android-how-to-format-the-text-as-table-in-email-body-of-email-client