Android:OnEditorActionListener无法正常工作

时间:2011-02-16 12:19:21

标签: android-edittext

我看到一些post和make代码来检测“DONE”键盘按钮上的事件。   但是当实现它时,keycode返回6并且事件返回null.is有任何为什么要检测DONE按钮事件,我想改变焦点。

textEdit5.setOnEditorActionListener(new OnEditorActionListener() {

    public boolean onEditorAction(TextView arg0, int keycode, KeyEvent event) { 
      if(arg1 == KeyEvent.FLAG_EDITOR_ACTION){
        btnSave.requestFocus();
        return true;
      }

      return false;     
    }
);

谢谢。

1 个答案:

答案 0 :(得分:-2)

请查看http://dev.bostone.us/2009/11/04/android-show-and-hide-soft-keyboard-programmaticaly/#awp::2009/11/04/android-show-and-hide-soft-keyboard-programmaticaly/

  

如果你想在按钮上设置焦点,那么btnSave.requestFocusFromTouch();

谢谢。

相关问题