简体   繁体   中英

Path for assets for html

please help.. I have a HTML code to display a webview but the styles are found in the assets folder and need to put the path to these files in HTML and tried in various ways but /src/main/assets/web.css file: ///android_asset/web.css does not work. could say me how .

Suppose there is one folder inside asset named: home and there is one file index.html inside home folder. So to load index.html i write code like this:

    WebView mWebView = (WebView) findViewById(R.id.webView);

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);

    mWebView.loadUrl("file:///android_asset/home/index.html");

I hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM