I\'m having a bit of trouble preserving the scroll position of a list view when changing it\'s adapter\'s data.
What I\'m currently doing is to create a custom Array
In your Expandable/List Adapter, put this method
public void refresh(List dataList) {
mDataList.clear();
mDataList.addAll(events);
notifyDataSetChanged();
}
And from your activity, where you want to update the list, put this code
if (mDataListView.getAdapter() == null) {
MyDataAdapter myDataAdapter = new MyDataAdapter(mContext, dataList);
mDataListView.setAdapter(myDataAdapter);
} else {
((MyDataAdapter)mDataListView.getAdapter()).refresh(dataList);
}
In case of Expandable List View, you will use mDataListView.getExpandableListAdapter() instead of mDataListView.getAdapter()