Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display html formated table using webview in Android

Tags:

android

I am trying a lot but it is not wroking. Here's my code:

public class SchofferStr extends Activity {

    String summary = "<html><body>You scored <b>192</b> points.</body></html>";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        WebView webview = new WebView(this);
        setContentView(webview);
        webview.loadData(summary, "text/html", "utf-8");
    }

}

the summary string i have is a lengthy htmlformatted table. But problem is this code is not even working for this simple html formated string. What is it that im doing wrong? Please help, im stuck.

like image 673
Rizwan Avatar asked Sep 10 '26 04:09

Rizwan


1 Answers

Try:

webview.loadDataWithBaseURL(null, summary, "text/html", "UTF-8", null);
like image 125
CommonsWare Avatar answered Sep 12 '26 18:09

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!