开发者

android keycode :KeyEvent.KEYCODE_SEARCH

开发者 https://www.devze.com 2023-03-01 01:16 出处:网络
hi i have edittext with imeoption actionsearch ,when i click search icon in virtual keyboard i need to invoke a function, i have ove开发者_开发技巧rride onKeydown but i won\'t get controll when i pres

hi i have edittext with imeoption actionsearch ,when i click search icon in virtual keyboard i need to invoke a function, i have ove开发者_开发技巧rride 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;
        }
    });


search_edit.setOnKeyListener(new OnKeyListener() {

                @Override
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    System.out.println("The key pressed onkeylistenere is having code: "+keyCode);
                    System.out.println("The key pressed onkeylistenere is having event: "+event);

                    return false;
                }
            });

try this & press "search" get the keycode & use

0

精彩评论

暂无评论...
验证码 换一张
取 消