How to display HTML table with rows and columns in WebView in Android.
Give me some example.
How to display HTML table with rows and columns in WebView in Android.
Give me some example.
Create an HTML
template
String myTable = "<table border=1>" +
"<tr>" +
"<td>row 1, cell 1</td>" +
"<td>row 1, cell 2</td>" +
"</tr>" +
"<tr>" +
"<td>row 2, cell 1</td>" +
"<td>row 2, cell 2</td>" +
"</tr>" +
"</table>";
and load into your WebView
myWebView.loadDataWithBaseURL(null, myTable, "text/html", "utf-8", null);
Its also working for me:
String tag = "<table border=1>" +
"<tr>" +
"<td>row 1, cell 1</td>" +
"<td>row 1, cell 2</td>" +
"</tr>" +
"<tr>" +
"<td>row 2, cell 1</td>" +
"<td>row 2, cell 2</td>" +
"</tr>" +
"</table>";
((WebView) findViewById(R.id.web)).loadData(tag, "text/html", "utf-8");
I think that this is an issue related to Android web view's in 2.2 and 2.3. The table tags like width, cell-spacing, and cell-padding are not supported in some web views and thus should not be used. If you want to style a table with webView.loadData(), use inline stlying with the style tag only.
Table border should also be removed as well.