如何显示的WebView谷歌Android默认的搜索结果?搜索结果、WebView、谷歌、Android

2023-09-06 18:39:36 作者:几两放荡

我要显示默认的谷歌搜索结果在我的Andr​​oid应用程序的web视图。我们可以使用谷歌自定义搜索的API做,但它的支付。我想使用谷歌默认搜索替换此API。能否请你帮我提供其执行情况。

I want to display default Google search Results in webview of my Android application. We can do it using Google Custom Search API but its is paid. I want to use Google default search to replace this API. Could you please help me to provide its implementation.

在此先感谢

推荐答案

如果我得到你的问题正确的,要允许用户输入搜索词,然后让谷歌搜索结果中的的WebView 。如果你仔细发现,然后在浏览器如果您输入以下网址: https://www.google.com/search?q=query_string ,那么你会得到结果你的 QUERY_STRING 查询。

If I get your question correct, you want to enable the user to enter a search term and then get google results in the webview. If you carefully notice, then in your browser if you enter following URL: https://www.google.com/search?q=query_string, then you will get results for your query of query_string.

那么,你的目的:

第1步您可以有一个的EditText 按钮

第2步在按一下按钮,你可以从文本的的EditText

Step 2 On Button click you can get the text from an EditText

第3步,然后创建一个从您从EditText上收到的查询字​​符串的URL如下:

Step 3 Then Create a URL from the query string that you received from EditText as follows:

String query; // Get the text from EditText here
String url = "https://www.google.com/search?q="+query;

第四步: 然后使用可以显示的URL结果的WebView该URL。

Step 4: Then using that URL you can display the URL result in webview.

结果将显示在那里。有许多线程,这将帮助你实现这一目标。有些是:

The results would be displayed there. There are many thread which will help you achieve this. Some are:

如何从EditText上获得的文字?的

1)如何从EditText上?

如何的WebView?显示网址的

1)试图显示URL中的Web视图

2)查看一个网页内的应用程序吗?

您唯一的任务是创建URL,然后显示可以通过web视图。

Your only task is to create the URL and then display is using webview.

希望它帮助。祝一切顺利。

Hope it helps. All the best.