5

我想在 web 视图中添加引线横幅广告。下面是广告代码

<script type="text/javascript" src="http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx"></script>

我将如何添加这个?

4

2 回答 2

3

WebView have a method called loadData(). Allow webview load html code directly.You could have a try.

String js_str = "<script type='text/javascript' src='http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx'></script>"

WebView webview = new WebView();

webview.loadData(js_str, null, null);
于 2012-09-04T05:40:48.020 回答
1

尝试这个

WebView wv = (WebView)findViewById(R.id.webViewad); 
wv.getSettings().setJavaScriptEnabled(true);
StringBuilder htmlData = new StringBuilder("<html>"); 
htmlData.append("<head><title>Ad</title></head>"); 
htmlData.append("<body>"); 
htmlData.append("<script type=\"text/javascript\" 
src=\"http://ad.leadboltads.net/show_app_ad.js?section_id=YOUR_ID\"></script>"); 
htmlData.append("</body>"); 
htmlData.append("</html>"); 
wv.loadData(htmlData.toString(),"text/html", "ISO 8859-1");
于 2013-04-18T19:24:35.540 回答