本文介绍了Android的关键code:KeyEvent.KEY code_SEARCH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有EDITTEXT与imeoption actionsearch,当我点击虚拟键盘搜索图标我需要调用一个函数,我有覆盖的onkeydown但我不会得到控制研究,当我preSS搜索,我做什么


解决方案

  ed1.setOnEditorActionListener(新OnEditorActionListener(){
        @覆盖
        公共布尔onEditorAction(TextView的V,INT actionId,KeyEvent的事件){
        如果(actionId == EditorInfo.IME_ACTION_SEARCH){
            的System.out.println(搜索pssed $ P $ .........);
        }
            返回false;
        }
    });

hi i have edittext with imeoption actionsearch ,when i click search icon in virtual keyboard i need to invoke a function, i have override onKeydown but i won't get controll when i press search , what i do

解决方案
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;
        }
    });

这篇关于Android的关键code:KeyEvent.KEY code_SEARCH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 06:33