i'm having trouble done/enter/next key. i'm making android soft keyboard , whenever try search can't because when press done key cursor moves next row. here code:
xml
<key android:keylabel="done" android:keywidth="11.11%" android:codes="-1"/>
java
@override public void onkey(int primarycode, int[] keycodes) { inputconnection ic = getcurrentinputconnection(); switch(primarycode){ case -1: ic.sendkeyevent(new keyevent(keyevent.action_down, keyevent.keycode_enter)); break; default: char code = (char)primarycode; if(character.isletter(code) && caps){ code = character.touppercase(code); } ic.committext(string.valueof(code), 1); } }
example: if search on google , type want , when click done key want start search. can please me that. in advance.
instead of
ic.sendkeyevent(new keyevent(keyevent.action_down, keyevent.keycode_enter));
try
ic.performeditoraction(editorinfo.ime_action_go);
the action performed should 1 defined on editorinfo, passed on method onstartinputview
to switch between actions, use this:
(seditorinfo.imeoptions & (editorinfo.ime_mask_action|editorinfo.ime_flag_no_enter_action))
hope helps.
code:
case -1: switch (seditorinfo.imeoptions & (editorinfo.ime_mask_action|editorinfo.ime_flag_no_enter_action)) { case editorinfo.ime_action_go: ic.performeditoraction(editorinfo.ime_action_go); break; case editorinfo.ime_action_next: ic.performeditoraction(editorinfo.ime_action_next); break; case editorinfo.ime_action_search: ic.performeditoraction(editorinfo.ime_action_search); break; case editorinfo.ime_action_send: ic.performeditoraction(editorinfo.ime_action_send); break; default: ic.sendkeyevent(new keyevent(keyevent.action_down, keyevent.keycode_enter)); break; } break;
Comments
Post a Comment