Organized from: http://hi.baidu.com/doyee/blog/item/e2a8481628ebed4521a4e948.html
Http://groups.google.com/group/android-developers/browse_thread/thread/fe95e6e838ee48b1? PLI = 1 In edittext, you can use the setimeoptions () method to enable the "done" button of the soft keyboard. Example Code As follows: Edittext. setimeoptions (editorinfo. ime_actIon_done ); The interface is as follows:
press " done " by default, the keyboard is disabled, however, you can use edittext setoneditexceptionlistener () method On editexceptionlistener to add your own behavior. capture the android text input box's keyboard complete (done) button message:
- Edittext. setoneditexceptionlistener (NewEdittext. OnEditexceptionlistener (){
-
-
- @ Override
- Public Boolean On editpartition tion (textview V, int actionid, keyevent event) {
- If(Actionid = editorinfo. ime_actIon_done ){
-
- Inputmethodmanager Imm = (inputmethodmanager) v. getcontext (). getsystemservice (context. input_method_service );
- Imm. hidesoftinputfromwindow (V. getwindowtoken (),0);
-
-
- Dosomething ();
-
- Return True;
-
- }
- Return False;
-
- }
-
-
- });
Editorinfo. ime_actIon_done It can be used together with other logos to set the keyboard, for example: Edittext. setimeoptions ( Editorinfo. ime_flag_no_extract_ui | Editorinfo. ime_actIon_done ); Note 1 : Editorinfo. ime_actIon_don E Only Android: singleline = "true" The edittext of is valid. At least for htc_a9191. NOTE 2: Editorinfo. ime_actIon_don E , Some input methods do not support it, such as the Sohu Pinyin input method.