【问题标题】:Let a webview load a website based on text input让 webview 根据文本输入加载网站
【发布时间】:2016-11-20 09:36:50
【问题描述】:

我目前正在编写自己的搜索引擎,我想加载 WebView,它使用以下搜索为我执行搜索:

我在用户输入搜索关键字的布局顶部放置了一个输入框,例如“Android Webview”。所以,当用户在他的键盘上搜索或输入时,我想让我的 WebView SearchWebView 加载以下 URL:http://searchengine.com/search= 输入的文本

我该怎么做?

谢谢

【问题讨论】:

    标签: android


    【解决方案1】:

    WebView documentation 可以为您提供帮助!

     webview.loadUrl("http://searchengine.com/search="+textInput.getText());
    

    点击键盘的“完成”:

    textView.setOnEditorActionListener(new OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId,
                    KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                   webview.loadUrl("http://searchengine.com/search="+textInput.getText());
                }
                return false;
            }
        });
    

    在您的 EditText xml 中:

       android:imeOptions="actionDone"
    

    【讨论】:

    • 我应该在哪个事件上让 WebView 做到这一点(当用户准备好时,他在键盘的搜索图标上键入)??
    • 回复更新!我认为这就是你所需要的。对吗?
    • 我会检查并在几分钟内报告!提前致谢!
    猜你喜欢
    • 2016-02-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    • 2017-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多