How to execute html in an activity? [duplicate]

-2

How do I make my application run a saved html file in a folder within the application?

    
asked by anonymous 06.04.2017 / 19:57

1 answer

3

Just open the file in a WebView .

Add to WebView I your layout file:

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/webview"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
    />

And in your Activity you load the contents of the file, like this:

setContentView(R.layout.my);
    WebView mWebView = null;
    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl("file:///android_asset/new.html"); //local do arquivo .html

For other examples, you can look at this question.

    
06.04.2017 / 20:09