简体   繁体   English

长时间按下软键盘上的退格键导致错误

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

I have a search area (EditText) with addTextChangedListener . 我有一个具有addTextChangedListener的搜索区域(EditText)。 When an input comes, my AsyncTask , which is in afterTextChanged method starts up. 输入输入后,位于afterTextChanged方法中的AsyncTask afterTextChanged启动。

  • In onPreExecute method, the dialog with the message of "please wait" is shown. onPreExecute方法中,显示带有“请稍候”消息的对话框。
  • In doInBackground method, items are filtered doInBackground方法中,将过滤项目
  • In onPostExecute method, filtered items are written to the list, after that the "please wait" dialog is stopped. onPostExecute方法中,将过滤的项目写入列表,此后将停止“请稍候”对话框。

Suppose that there is a word with 6 characters in the search area. 假设在搜索区域中有一个包含6个字符的单词。 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). 但是在这里,我得到了错误IllegalStateException (适配器的内容已更改,但ListView没有收到通知)。

Although I use the notifyDataSetChanged method in postExecute . 虽然我用的是notifyDataSetChanged的方法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;
            } 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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