onEditorAction()不叫回车键后一直pssed上果冻豆仿真器$ P $ [英] onEditorAction() is not called after Enter key has been pressed on Jelly Bean emulator

查看:275
本文介绍了onEditorAction()不叫回车键后一直pssed上果冻豆仿真器$ P $的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用最新的果冻豆仿真器的行为存在问题。我有几个 EditTexts 在我的应用程序。一个 OnEditorActionListener 提供了特殊的处理,当用户presses键盘上的回车键。这个工作,直到ICS,但现在对果冻豆的侦听器回调方法 onEditorAction()不再被调用。只有一个新行插入的EditText

I'm having a problem with the behavior of the latest Jelly Bean emulator. I have several EditTexts in my app. An OnEditorActionListener provides special handling when a user presses the ENTER key on the keyboard. This worked up until ICS, but now on Jelly Bean the listener callback method onEditorAction() no longer gets called. Only a new line is inserted into the EditText.

这可以重现这种方式:

EditText testEditText = new EditText(context);
testEditText.setOnEditorActionListener(new OnEditorActionListener() {

    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        Log.d(TAG, "onEditorAction() called");
        return false;
    }
});
addView(testEditText);

这是在果冻豆中的错误?或者在模拟器?或者有行为改变故意?

Is this a bug in Jelly Bean? Or in the emulator? Or has the behavior been changed intentionally?

奇怪的是别人写,该方法被调用,但意外的参数,在一台Nexus 7上运行果冻豆的位置:<一href="http://stackoverflow.com/questions/11301061/null-keyevent-and-actionid-0-in-oneditoraction-jelly-bean-nexus-7">null KeyEvent的和actionid = 0 onEditorAction()(果冻豆/的Nexus 7)

Curiously someone else writes that the method gets called, but with unexpected parameters, on a Nexus 7 running Jelly Bean here: null keyevent and actionid = 0 in onEditorAction() (Jelly Bean / Nexus 7)

推荐答案

如果别人发现了这个问题:

If someone else finds this question:

我测试过几次,并在果冻豆仿真器监听回调方法onEditorAction()确实不再被调用时,回车键是pssed在虚拟键盘上$ P $。

I've tested this several times and on the Jelly Bean emulator the listener callback method onEditorAction() indeed no longer gets called when the Enter key is pressed on the virtual keyboard.

正如我上面提到的一个可能的解决方案或替代方法是用现有的操作键之一替代Enter键。那些依旧会触发onEditorAction()。我也有指定的输入类型。

As I mentioned above a possible solution or workaround is to replace the Enter key with one of the available action keys. Those still trigger onEditorAction(). I also had to specify the input type.

editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
editText.setImeOptions(EditorInfo.IME_ACTION_GO);

<EditText
...
android:imeOptions="actionGo"
android:inputType="text" />

这篇关于onEditorAction()不叫回车键后一直pssed上果冻豆仿真器$ P $的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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