Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display HTML Table in webview

How to display HTML table with rows and columns in WebView in Android.

Give me some example.

like image 318
Android_prog Avatar asked Aug 19 '10 19:08

Android_prog


2 Answers

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);
like image 142
Jorgesys Avatar answered Oct 21 '22 08:10

Jorgesys


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");
like image 29
Pratik Butani Avatar answered Oct 21 '22 06:10

Pratik Butani