The oneditexception listening event in EditText is executed twice,
Android EditText uses setoneditexceptionlistener to set a listening event for the text editing box. However, the logic in oneditexception triggers the event twice after each carriage return, this method is triggered when the ACTION_UP and ACTION_DOWN values of the keyboard press enter are used. Therefore, the following code is modified to prevent two executions:
1 public boolean oneditequaltion (TextView v, int actionId, KeyEvent event) {2 // The following method prevents two requests from sending 3 if (actionId = EditorInfo. IME_ACTION_SEND | 4 (event! = Null & event. getKeyCode () = KeyEvent. KEYCODE_ENTER) {5 switch (event. getAction () {6 case KeyEvent. ACTION_UP: 7 // send request 8 String keyWord = et_search.getText (). toString (). trim (); 9 if (null = keyWord) 10 keyWord = ""; 11 dismisspopup (); 12 LogUtils. d ("Send search request to server:" + keyWord); 13 // initiate query 14 searchByKeyWord (keyWord); 15 hideSoftInput (); 16 return true; 17 default: 18 return true; 19} 20} 21 return false; 22}