The virtual keyboard in the search box
The XML is as follows
<EditTextAndroid:id= "@+id/et_shopshow_search"Android:layout_width= "144DP"Android:layout_height= "40DP"Android:singleline= "true"Android:paddingleft= "8DP"Android:paddingright= "8DP"android:drawablepadding= "8DP"Android:hint= "@string/kuanhao"Android:background= "@color/white"Android:drawableleft= "@drawable/searchcommon_icon"Android:focusableintouchmode= "true"android:textsize= "16SP"Android:layout_marginleft= "8DP"Android:layout_marginright= "8DP"Android:layout_weight= "1"android:imeoptions= "Actionsearch" />
Add KeyDown time rewrite to the code
FinalEditText et_search=(EditText) Findviewbyid (R.id.et_shopshow_search); Et_search.setoneditoractionlistener (NewOneditoractionlistener () {@Override Public BooleanOneditoraction (TextView V,intActionId, KeyEvent event) { if(ActionId = =Editorinfo.ime_action_search) {//This is a search//hide the keyboard first((Inputmethodmanager) Et_search.getcontext (). Getsystemservice (Context.input_method_service)) . Hidesoftinputfromwindow (shopshowactivity. This. Getcurrentfocus (). Getwindowtoken (), inputmethodmanager.hide_not_always); //query based on the contents of the search box_stylecode=V.gettext (). toString (). Trim (); Initpagetask Task=NewInitpagetask (shopshowactivity. This); Task.execute (""); return true; } return false; } });
Android Custom Search box