4
我有一個WebView。我想加載一個名爲helloworld.html的本地HTML文件。它位於我的drawable-hdpi文件夾中。無法在Android WebView中加載本地HTML文件
這裏是我的代碼:
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/helloworld.html");
我得到一個瀏覽器錯誤:
The webpage at file:///android_asset/helloworld.html could not be loaded as the file requested was not found. /android_asset/helloworld.html (no such file or directory)
我該如何解決?
爲什麼html文件位於可繪製文件夾中? –
呼叫良好。我創建了一個名爲/ assets的文件夾,它起作用。你應該發佈一個答案:) –