-1

How to load data from string value on webview? I've try this:

web.loadData(getResource().getString(R.string.webdata), "text/html","UTF-8");

But it get error. Please, help me.

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
  • 1
    Please explain, **in detail**, what "it get error" means. Also, please provide the string resource file where you have defined `webdata`. – CommonsWare Apr 21 '17 at 21:33
  • I say get error because it force close, and the webdata contain html code. like
    – user7720433 Apr 21 '17 at 21:38
  • 1
    "I say get error because it force close" -- then use LogCat to examine the Java stack trace associated with your crash: http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this. Also, please note that your HTML is invalid. – CommonsWare Apr 21 '17 at 21:44
  • I use AIDE, and my code is invalid. – user7720433 Apr 21 '17 at 21:50

1 Answers1

0

try this

WebView webview = (WebView)this.findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadDataWithBaseURL("", data, "text/html", "UTF-8", "");
Pablo Escobar
  • 393
  • 2
  • 16