I have a listview that displays a list of contacts. I added an EditText to the layout above the list so I can search with a filter. I implemented this using the onTextChanged listener in EditText. My listview adapter is a custom adapter that extends BaseAdapter and implements Filterable. My filter works and does the job correctly. The problem is that when I type, the data set is updated, but the list itself is not updated until I hide the keyboard or press the return key. If I try to click on the list after entering some text in EditText, but before I close the keyboard or press the return key, I get this error:
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.
Now, I definitely do not change the contents of the adapter from a thread other than a user interface thread.
Can someone explain what might cause this problem?
Actually, I found a workaround by calling Activity.onContentChanged() , but I'm still wondering why I really need to update manually.
android filter listview
Hbibna
source share