0
votes

I have a webView in my Android application that I load string into using loadData() method. I later want to reset the data I loaded into webView and load a URL using loadUrl() method. However, even if I later call loadUrl() with the URL that I need, I cannot reset the webView - it still shows the string I loaded previously. What should I do?

if (!text.isEmpty() && latexText.isEmpty()) {
    webView.setBackgroundColor(Color.parseColor("#EED5C9"));
    String format = "<html><body style=\"text-align:justify\"> %s </body></Html>";
    String data = getString(R.string.invalidChar);
    webView.loadData(String.format(format, data), "text/html", "utf-8");
    return;
}


webView.setBackgroundColor(Color.WHITE);
if (android.os.Build.VERSION.SDK_INT < 19) {
    webView.loadUrl("javascript:document.getElementById('math').innerHTML='\\\\["
        +doubleEscapeTeX(latexText)+"\\\\]';");
    webView.loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);");
} else {
    webView.evaluateJavascript("javascript:document.getElementById('math').innerHTML='\\\\["
        +doubleEscapeTeX(latexText)+"\\\\]';", null);
    webView.evaluateJavascript("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);", null);
}
1
Please share the code you are using!Anis LOUNIS

1 Answers

0
votes

use:

webview.clearView();

it will clear the view from webview.