I can finally figure out what happen.
I am using “com.quinny898.library.persistentsearch:library:1.1.0-SNAPSHOT”.
When I try to do “notifyDataSetChanged();” in another ListViewAdapter, this error message shows up.
Error Message:
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. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131690277, class android.widget.ListView) with Adapter(class com.quinny898.library.persistentsearch.SearchBox$SearchAdapter)] : at android.widget.ListView.layoutChildren(ListView.java:1597)
Solution!
You Should call closeSearch() when search box is closed;
@Override public void onSearch(String searchTerm) { closeSearch();//Important! } @Override public void onResultClick(SearchResult result) { //React to result being clicked closeSearch();//Important! } @Override public void onSearchCleared() { }
protected void closeSearch() { search.hideCircularly(MainActivity.this); search.clearResults(); }