Display html formatted table using webview in Android

I try a lot, but it does not unfold. Here is 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");
    }

}

summary row i have a long htmlformatted table. But the problem is that this code does not even work for this simple formatted HTML string. What is this wrong behavior? Please help, I'm stuck.

+3
source share
1 answer

Try:

webview.loadDataWithBaseURL(null, summary, "text/html", "UTF-8", null);
+8
source

Source: https://habr.com/ru/post/1776119/


All Articles