How to run html on an Activity?

Asked

Viewed 116 times

-2

How do I have my application run an html file saved to a folder within the application?

  • how do I run? Voce speaks open the page in a given space for example? if yes just use a webview

  • more the webview , I can run it from a file ? or it is only via link of websites?

1 answer

3


Just open the file in a Webview.

Add to WebView me 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 his Activity you upload the contents of the file in this way:

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

If you want other examples, you can look at this question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.