我使用机器人:imeOptions = “actionSearch”

在EDITTEXT和我的问题是我可以写我自己的事件,如果用户按下搜索按钮上Softkeyboard?

actualy我想执行类似于按钮我们用机器人活动softkeyboard搜索按钮的功能。

任何帮助将appriciated。

有帮助吗?

解决方案

这是我最后使用:

EditText SearchEditText = (EditText) findViewById(R.id.txtMapSearch);
SearchEditText.setOnEditorActionListener(new OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
        // TODO Auto-generated method stub
        if (arg1 == EditorInfo.IME_ACTION_SEARCH) {
            // search pressed and perform your functionality.
        }
        return false;
    }
});

其他提示

setOnEditorActionListener()注册一个EditText当用户轻敲软键盘上的动作按钮将被调用呼叫TextView.OnEditorActionListener

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top