Android v2.2-2.3.5: WebView : loadDataWithBaseURL : will only load page once

佐手、 提交于 2019-12-24 01:59:46

问题


When I'm loading a page using .loadData or .loadDataWithBaseURL, the system will load a page once.

After that, subsequent calls do not work.

In 4.0.3, if I were to call the function a second time with new data, it does change.

How can I fix this for 2.2+? Do I destroy the webview and create a new one?

webView1.loadDataWithBaseURL("file://", page, "text/html", "UTF-8", null);
webView1.loadUrl( "javascript:window.location.reload( true )" );

回答1:


In loadDataWithBaseURL, set the last parameter to the URL where that data came from, instead of null.




回答2:


I think it should be "file:///". You just missed one slash.



来源:https://stackoverflow.com/questions/9960443/android-v2-2-2-3-5-webview-loaddatawithbaseurl-will-only-load-page-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!