本地網站(HTML),我想在我的Android應用程序添加一個網站,我想離線導航,而不使用網絡servor。 我的意思是當我點擊網站時,它將打開沒有互聯網。可能嗎 ? 謝謝使用android系統中
回答
正常,則: 首先搭配的HTML,CSS,JS或其他文件,你需要在同一文件夾收取做「簡單的方法」,但如果你希望你可以爲每一個使用diferents路徑。
要加載網頁:
urlcapitulo = "file:///android_asset/youweb.html"; //change for you html file
web = (WebView) findViewById(R.id.webkit); //using webview declare in xml
web.getSettings().setJavaScriptEnabled(true); // enable javascript
web.getSettings().setBuiltInZoomControls(true); // add zoom button
web.loadUrl(urlcapitulo); // load url
你好兄弟。 ?它不工作的兄弟:( –
那是爲我工作,你一定要與路徑我有10個應用程序使用此代碼 – josedlujan
這裏1:https://play.google.com/store/apps/details?id=com。 manual.html.basico.desarolloweb.com – josedlujan
你嘗試過到現在怎麼辦?發佈您的代碼。 Stackoverflow不是爲你製作應用程序。它關於解決您面臨的任何問題。一個簡單的谷歌搜索給了我很多結果你的問題。
以下是here採取:
WebView wv = new WebView(this);
StringBuilder html = new StringBuilder();
html.append("<html>");
html.append("<head>");
html.append("<link rel=stylesheet href='css/style.css'>");
html.append("</head>");
html.append("<body>");
html.append("<h1>Some Heading</h1>");
html.append("<p>Some HTML content</p>");
html.append("<p><img style='width: 100%;' src='spidermen.jpg' /></p>");
html.append("</body></html>");
wv.loadDataWithBaseURL("file:///android_asset/", html.toString(), "text/html", "UTF-8", "");
See this爲好。
對於HTML文件,試試這個:
webView.loadUrl("file:///android_asset/filename.html");
我見過這之前,在我的情況下,我有10頁。我想要一個方法導入頁面不寫html代碼insite android類謝謝你的幫助 –
看到我的編輯(最後一行)。 –
- 1. 使用android系統中
- 2. 使用android系統中
- 3. 使android系統
- 4. 使用PopupWindow在android系統
- 5. 使系統應用的Android
- 6. 使用異常android系統
- 7. 查詢中使用WHERE在android系統
- 8. 其中有使用SAX在android系統
- 9. 使用Android系統中的FlightAware API
- 10. 在整個Android系統中使用FLAG_KEEP_SCREEN_ON
- 11. 無法使用android系統中
- 12. 調用android系統
- 13. 與android系統中
- 14. 如何使android系統
- 15. 在Android系統中讀取系統功能/用戶操作
- 16. 在android系統
- 17. android系統
- 18. 在android系統
- 19. android系統
- 20. android系統
- 21. android系統
- 22. android系統
- 23. NoSuchMethodException android系統
- 24. android系統
- 25. android系統
- 26. 讓android系統
- 27. 在android系統
- 28. NullPointException android系統
- 29. 在android系統
- 30. android系統
是的。把html放在'assets'文件夾中並使用WebView加載 – cYrixmorten
我應該把html放在所有的文件夾中嗎? cos我的網站包含其他文件夾 –
請詢問... 您想在您的應用程序中添加網站並稍後檢查? 你想在導航中的應用程序中使用網站的HTML文件? – josedlujan