Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓&x2B;WebView中的1个按钮_Android_Webview_Google Plus One - Fatal编程技术网

Android 安卓&x2B;WebView中的1个按钮

Android 安卓&x2B;WebView中的1个按钮,android,webview,google-plus-one,Android,Webview,Google Plus One,我试着用他们描述的方法将Google的+1按钮放到WebView中。我已初始化WebView,如下所示: final WebView web = (WebView)findViewById(R.id.webView); web.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); web.getSettings().setJavaScriptEnabled(true); web.getSettings().setSavePas

我试着用他们描述的方法将Google的+1按钮放到WebView中。我已初始化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="http://stackoverflow.com"></g:plusone>

问题是。。。按钮根本不显示

我怎么修理它?顺便说一句,我还希望按钮启动一个新窗口,而不是使用WebView。有简单的解决办法吗


谢谢

我对WebView不是很有经验,但是按钮根本没有显示出来,这听起来可能是layout/main.xml文件中的一个问题。你看过这个了吗


另外,对于启动新窗口的按钮,我认为可以附加一个setOnClickListener,一旦完成,就将其视为一个按钮,并打开一个新窗口。我希望这是可能的。

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

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

按钮将出现,但不幸的是,它在WebView中无法正常工作。

您的答案根本没有帮助。布局没有问题,很容易检查。WebView用于使用webkit呈现HTML网站,因此很容易检查它是否显示。至于按钮,它是WebView中的一个按钮。无法将任何侦听器附加到它。