Reputation: 715
I want to add leadbolt banner ad in a webview. Here is the ad code below
<script type="text/javascript" src="http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx"></script>
How will I add this?
Upvotes: 5
Views: 3217
Reputation: 591
try this
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");
Upvotes: 0
Reputation: 1228
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);
Upvotes: 3