android keycode :KeyEvent.KEYCODE_SEARCH

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

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

回答1:

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;         }     }); 


回答2:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!