【发布时间】:2016-01-20 16:01:18
【问题描述】:
我正在尝试将 versionName 字符串传递给 webview 并在我的 html 页面上显示该字符串。这是我尝试过的。
try {
myWebView.getSettings().setJavaScriptEnabled(true);
String versionName = getPackageManager()
.getPackageInfo("com.chad.flashupdate", 0)
.versionName;
myWebView.loadUrl("javascript:init('" + versionName + "')");
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
然后我尝试使用这个来加载和显示字符串。
$( document ).ready(function() { $("#MyEdit").html(versionName); });
在我的 html 中我放了这个。
<div id="MyEdit"><B>
versionName will be displayed here!
</B></div>
当我尝试什么都没有发生时,这意味着 div 文本永远不会改变。所以也许 webview 没有加载字符串。感谢您的帮助!
【问题讨论】: