android keycode :KeyEvent.KEYCODE_SEARCH
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
精彩评论