WebView中的Android 1按钮

我已经尝试使用他们描述的方法在GoogleView中放置Google的1个按钮.我已经初始化了WebView,如下所示:

final WebView web = (WebView)findViewById(R.id.webView);
web.getSettings().setJavaScriptCanopenWindowsAutomatically(true);
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setSavePassword(false);
web.getSettings().setBuiltInZoomControls(false);
web.getSettings().setUseWideViewPort(true);
web.getSettings().setLoadWithOverviewmode(true);
web.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
web.setHorizontalScrollBarEnabled(false);
web.setBackgroundColor(0xff2e2e2e);
web.loadDataWithBaseURL(null, htmlCodeGoesHere, "text/html", "utf-8", null);

HTML代码

<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<g:plusone href="https://stackoverflow.com"></g:plusone>

问题是……按钮根本不显示.

我如何解决它?顺便说一句 – 我也希望按钮能够使用WebView启动新窗口.有简单的解决方案吗?

谢谢

解决方法:

问题在于WebView中的权限系统.本地文件中的脚本在访问外部资源时遇到问题.解决方案是让WebView认为本地代码是从外部网站加载的.

web.loadDataWithBaseURL("http://fake.com", htmlCodeGoesHere, "text/html", "utf-8", null);

该按钮将出现,但不幸的是它在WebView中不能正常工作.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...