While using WebView, we usually put a URL for it:
WebView.loadUrl(myURL);
but it is possible to put HTML code directly?? So that it will be in a logic that:
WebView.loadContent ( <html><head><script></script></head><body>....</body></html> );
Thanks.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken web view to show html content.
The loadUrl() and loadData() methods of Android WebView class are used to load and display web page.
Yes you can, you can use javascript to get webpage content. Then use the webview jsInterface to return the content to you java code.
Check out this: http://developer.android.com/reference/android/webkit/WebView.html
// OR, you can also load from an HTML string: String summary = "<html><body>You scored <b>192</b> points.</body></html>"; webview.loadData(summary, "text/html", null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With