Sometimes we need to change "Go" or "Go" in the lower right corner of the keyboard after the output is completed; usually we need to set the Android:imeOptions property. The values of Android:imeOptions include actionGo, actionSend, actionSearch, actionDone, etc.
But today I found that the setting was invalid. That's because I set android:maxLines="1"
The solution is to remove android:maxLines="1" and set android:singleLine="true". If necessary, inputType is set to text.
There is a way to write a monitoring click Enter on the Internet. This way to write a search will be executed twice. The solution is
(new () { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId==EditorInfo.IME_ACTION_SEND ||(event!=null&&()== KeyEvent.KEYCODE_ENTER)) { //do something; return true; } return false; } });
The solution is 1 (I feel that the writing method is a bit redundant)
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { //The following method prevents two requests from being sent if (actionId == EditorInfo.IME_ACTION_SEND || (event != null && () == KeyEvent.KEYCODE_ENTER)) { switch (()) { case KeyEvent.ACTION_UP: //Send a request String keyWord = et_search.getText().toString().trim(); if (null == keyWord) keyWord = ""; dismisspopup(); ("Send a search request to the server:" + keyWord); //Start a query searchByKeyWord(keyWord); hideSoftInput(); return true; default: return true; } } return false; }
There is another way to write it. Just listen to actionId directly equals the time required for search.
EditText editText = (EditText) (); (new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { (getActivity(), "1111111",Toast.LENGTH_SHORT).show(); } return false; } });
The above is the solution to the problem of setting imeOptions in Android that the editor introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!