嗨,我有imeoption actionsearch的edittext,当我单击虚拟键盘中的搜索图标时,我需要调用一个函数,我已经覆盖了onKeydown,但是当我按search时,我将无法控制,我该怎么办

最佳答案

ed1.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if(actionId==EditorInfo.IME_ACTION_SEARCH){
            System.out.println("Search pressed.........");
        }
            return false;
        }
    });

10-07 22:34