2017-02-03 39 views
0

我加載的資產目錄HTML,這裏是我的代碼:無法打開資源網址:文件:///android_asset/test-wv/index.html

/家庭/ roroco/Dropbox的/合資/滾裝ADR /應用/ src目錄/主/ JAVA/RO/ADR /測試/ TestWv.java

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_test_wv); 
    WebView w = (WebView) findViewById(R.id.w); 
    w.loadUrl("file:///android_asset/test-wv/index.html"); 
} 

我敢肯定,這個HTML文件存在

/家庭/ roroco/Dropbox的/合資/ RO-ADR /app/src/main/assets/test-wv/index.html

回答

1

原因是「即時運行」,在我的第一個啓動網站看來,資產/是空的,所以當我加入的index.html資產/,「即時運行」不會刷新資產/修改,解決方法:

  • 方法1:清除即時運行 我必須:

    gradle這個:應用:uninstallDebug

,然後重新運行調試

  • 方法2:禁用即時運行(在tellij想法>設置>即時運行>關閉「啓用即時運行...」

如果你像我想的資產web應用程序寫入,禁用即時來看,如果沒有Java代碼moficiation,「啓用即時運行」和「禁用即時運行」將在我的代碼中花費相同的編譯時間