隐藏或禁用的WebView softkeyboard GO / DONE /回车按钮 [英] Hide or disable WebView softkeyboard Go/Done/Enter button

查看:163
本文介绍了隐藏或禁用的WebView softkeyboard GO / DONE /回车按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找这一整天的工作示例,并没有发现任何实际工作。

I've been searching for a working example of this all day and haven't found anything that actually works.

我有一个简单的反馈表网上我已经设置与的WebView在Android设备上运行,专为Nexus 7(它将只能在本地在我们的酒店在这些设备上使用)。

I have a simple feedback form online which I've setup with WebView to work on android devices, specifically for Nexus 7 (it will only be used locally at our hotel on these devices).

的一点是,HTML反馈表有不同的字段集,有的用单选按钮与其他文本字段和文本区域。该表格​​是通过邮寄方式发送,我有打电话的形式jQuery验证脚本:

The thing is that the html feedback form has different fieldsets, some with radio buttons others with text fields and text areas. The form is sent via post and I have a jquery validation script called in the form:

<form name="form" method="post" action="feedback_manager/fb_save.php" onsubmit="return validateForm()" >

一切都工作得很好,除了当用户在文本字段中有一个在他们必然要点击(或触摸),一旦他们完成打字软键盘蔚蓝色的转到按钮填补了,问题是它不带他们到下一个表单字段集,而是自动提交表单(或在这种情况下,第一次运行我的验证脚本)。

Everything works just fine, except for when a user fills in a text field there's an unmistakable blue "Go" button in the soft keyboard which they are bound to click (or touch) once they've finished typing, the problem is that it doesn't take them to the next form fieldset, instead it submits the form automatically (or in this case runs my validation script first).

不是关键code_ENTER按钮的默认操作应该给用户发送到下一个字段集,而不是提交表单的?

Isn't the KEYCODE_ENTER button's default action supposed to send the user to the next fieldset instead of submitting the form?

我将分享我的HTML形式,希望我的web视图脚本,有人可能会觉得我做错了什么:

I'll share my html form and my webView script in hopes that someone may find what I'm doing wrong:

<fieldset>
<legend>Food quality, taste &amp; presentation</legend>

    <input id="flavor4" name="flavor" value="excellent" type="radio" />
    <label for="flavor4"> Excellent</label><br>

    <input id="flavor3" name="flavor" value="good" type="radio" />
    <label for="flavor3"> Good</label><br>

    <input id="flavor2" name="flavor" value="average" type="radio" />
    <label for="flavor2"> Average</label><br>

    <input id="flavor1" name="flavor" value="bad" type="radio" />
    <label for="flavor1"> Needs improvement</label><br>

</fieldset>
<fieldset>
    <legend>Who was your waiter today?</legend>
    <input name="waiter" type="text">
</fieldset>

//then another fieldset with radio buttons and so on

难道说我的文字输入不是彼此后立即正确,并与单选按钮和组合框混合?

Could it be that my text inputs aren't immediately right after one another and mixed in with radio buttons and combo boxes?

下面是我的onkeydown code:

Here's my onKeyDown code:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack())
    {
        mWebView.goBack();
        return true;
    }
    if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
        // do nothing
        return false;
    }
    return true;
}

关于这个有趣的是,我的钥匙code_BACK条件是工作正常,但我想KEY code_ENTER按钮,要么什么也不做,只是关闭软键盘或进入下一个字段,但不提交的形式。

The funny thing about this is that my KEYCODE_BACK conditional is working fine but I would like the KEYCODE_ENTER button to either do nothing and just close the soft keyboard or go to the next field but not submit the form.

我见过很多答案在这里SO,但他们都不是工作在Nexus7(还没有真正尝试在其他设备上)。

I've seen a lot of answers here on SO but none of them seem to be working on Nexus7 (haven't really tried on other devices).

所以,总结,我需要的只是有一个蓝色的开始按钮,什么也不做,去下一个字段。

So summing up, all I need is just have that blue "Go" button do nothing or go to the next field.

请帮助。

** 修改 **

我今天早上看这一个别开生面,发现这个类似的职位,增加了一个OnKeyListener检测键,然后返回false。 上的EditText Enter键打安其两次

I'm looking at this with a fresh outlook this morning and found this similar post that adds an OnKeyListener to detect the key and then returns false. Enter key on EditText hitting onKey twice

mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl("http://some.url");
    mWebView.setWebViewClient(new virtuoWebViewClient());

    mWebView.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                if (keyCode == KeyEvent.KEYCODE_ENTER) {
                    // do nothing
                    return false;
                }
            }
            return false;
        }
    });

但依然一无所获,转到按钮,还提交表单:(,我会继续努力,如果有人可以点我的方向不同,或分享新的想法,我会大大AP preciate它。 THX。

But still nothing, the "Go" button still submits the form :(, I'll keep trying, if anybody could point me in a different direction or share new ideas, I'll greatly appreciate it. Thx.

推荐答案

OK,我不得不让这个煨,因为它有一个有点沮丧,大量的试验后错误似乎的WebView本身不会让我的行为打算对于没有的EditText。我并不真正需要的EditText这个应用程序,我发现输入类型的文本显示转到按钮,但文字区域不一样,他们使用回车键取代它(不是蓝色,不发送表格),它的廉价和粗糙,但适合的目的,所以我基本上结束了使用文本域的参数行=1,所以它看起来像一个输入类型的文本。

OK I had to let this simmer because it got a little frustrating, after lots of trial and error it seems that WebView by itself won't allow the behavior I was going for without EditText. I don't really need EditText for this app and I discovered that input type text shows the "Go" button but textareas don't, they replace it with a return carriage button (that isn't blue and doesn't send the form), it's cheap and rough but fits the purpose, so I basically ended up using textareas with the parameter rows="1" so it looks like an input type text.

<textarea rows="1" name="waiter"></textarea>

一个非常低技术的解决方案,以隐藏开始,完成或确定按钮XD。

A very low-tech solution to hide the "Go", "Done" or "Enter" buttons XD.

这篇关于隐藏或禁用的WebView softkeyboard GO / DONE /回车按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆