2017-10-13 54 views
0

//這是從那裏的HTML文件加載找不到文件的錯誤時HTML文件加載

progres = ProgressDialog.show(activity, "Please wait!", "Loading..."); 

      web.setWebViewClient(new WebViewClient() { 
      public void onReceivedError(WebView view, int errorCode, String 
      description, String failingUrl) { 
       Toast.makeText(activity, description, 
       Toast.LENGTH_SHORT).show(); 
      } 

      @Override 
      public void onPageFinished(WebView view, String url) { 
       super.onPageFinished(view, url); 
       progres.dismiss(); 
      } 
     }); 

     web.getSettings().setJavaScriptEnabled(true); 
     web.loadUrl("file:///android_assets/sample.html"); 
     } 
    } 

assets file location

+1

最後,我得到了我的解決方案o wn問題,我從資產文件夾路徑中刪除了「s」,例如「file:///android_asset/sample.html」 –

回答

0

嘗試這樣

web.loadUrl(getAssets().open("sample.html")); 
2
web.loadUrl("file:///android_asset/sample.html"); 

android_asset不android_assets