I have added a view to the header of listVivew,
View TopSearch = (View) View.inflate(this, R.layout.search, null);
lv.addHeaderView(TopSearch, null, false);
And everything is fine until I try to execute (when data changes)
adapter.notifyDataSetChanged();
That always crash my application giving me following error:
> java.lang.ClassCastException: android.widget.HeaderViewListAdapter
If I remove header view then there is no error. Any suggestions? Thanks.
It seems that whenever you use header/footer views in a listview, your ListView gets wrapped with a HeaderViewListAdapter. You can fix this using the below code:
((YourAdapter)((HeaderViewListAdapter)lv.getAdapter()).getWrappedAdapter()).notifyDataSetChanged();