To show a static html page in android

前端 未结 3 1404
闹比i
闹比i 2021-01-04 05:17

I am trying to show an html file in my assets folder but in web view i am seeing white blank page. I got similar example from stackflow only.

 public void on         


        
相关标签:
3条回答
  • 2021-01-04 05:54

    Uhm, did you try following the WebView example from the official webpage? It's really simple.

    http://developer.android.com/resources/tutorials/views/hello-webview.html

    I followed that and had no trouble implementing a WebView. Your code looks overly complicated for something that is quite simple.

    If your file is called pmi_help.html (and located in the /assets/ folder), you load it using:

        mWebView.loadUrl("file:///android_asset/pmi_help.html");
    
    0 讨论(0)
  • 2021-01-04 06:01

    you can load the content of the web view using

    // add a webview with id @+id/the_webwiev to your main.xml layout file
    WebView wv = (WebView)findViewById(R.id.the_webview);
    wv.loadUrl("file:///android_asset/myweb.html");
    
    0 讨论(0)
  • 2021-01-04 06:04

    Put your html page in asset > www, then load:

    mWebView.loadUrl("file:///android_asset/index1.html");
    
    0 讨论(0)
提交回复
热议问题