简体   繁体   中英

Error caused by pressing backspace button on the soft keyboard for too long

I have a search area (EditText) with addTextChangedListener . When an input comes, my AsyncTask , which is in afterTextChanged method starts up.

  • In onPreExecute method, the dialog with the message of "please wait" is shown.
  • In doInBackground method, items are filtered
  • In onPostExecute method, filtered items are written to the list, after that the "please wait" dialog is stopped.

Suppose that there is a word with 6 characters in the search area. When I press and hold the backspace button on the soft keyboard, characters are deleted one by one quickly.

But in here I get error IllegalStateException (the content of the adapter has changed but ListView did not receive a notification).

Although I use the notifyDataSetChanged method in postExecute .

What can I do to fix this?

 public boolean onKeyDown(int keyCode, KeyEvent event) {    

///forcontrol pressing backeSpace in editText(softKeyboard)

            if (keyCode == KeyEvent.KEYCODE_DEL) {

                parent.endsWith("");            

                return true;
            } 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM