android - Enter key listener for Google keyboard is not working -
i want add functionality on click of "enter" key of google's keyboard without vanquishing default newline characteristic. have used onkeylistener not working.
edittext edittext = (edittext) findviewbyid(r.id.user_query); edittext.setonkeylistener(new onkeylistener() { public boolean onkey(view v, int keycode, keyevent event) { if ((event.getaction() == keyevent.action_down) && (keycode ==keyevent.keycode_enter || keycode == keyevent.keycode_dpad_center)) { //here want print numbers next line in edit text return true; } return false; } });
the same code working other keyboards.
as stated here
interface definition callback invoked when hardware key event dispatched view. callback invoked before key event given view. useful hardware keyboards; software input method has no obligation trigger listener.
and safe bet use addtextchangedlistener in case below
edittext.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence s, int start, int before, int count) { //here code } @override public void beforetextchanged(charsequence s, int start, int count, int after) { // todo auto-generated method stub } @override public void aftertextchanged(editable s) { // todo auto-generated method stub } });
Comments
Post a Comment