使用imeOptions

Android的软键盘右下角有Action按钮,如下图的“上一步”

 

 

在EditText中有 android:imeOptions选项,它包括完成按钮“actionDone”,发送按钮“actionSend”等动作。

 

如何使用android:imeOptions呢?让EditText实现setOnEditorActionListener,在onEditAction方法中actionId就对应我们设置的imeOptions。

 

private TextView.OnEditorActionListener mWriteListener =
        new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
           
            if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_UP) {
             
            }
          
            return true;
        }
    };

 

KeyEvent.ACTION_UP表示按键松开。

KeyEvent.ACTION_DOWN 表示按键按下。

 

posted on 2015-11-11 18:01  屌丝迷途  阅读(853)  评论(0编辑  收藏  举报

导航