Can someone explain me why the following code does not work? I am trying to update my list of Report everytime the user clicks the refresh button with the following code
In updateReports
(after all the download of data and the parsing):
reportsList = newReportsList;
listAdapter.notifyDataSetChanged();
Previously in onCreateView
:
listAdapter = new ReportsListAdapter(activity, R.layout.list_item_reports, reportsList);
listView.setAdapter(listAdapter);
But the list does not refresh and keeps showing the old reports. I tried with listAdapter.clear()
and listAdapter.add()
with a for
(I can not use addAll
because I need to work with API 10) but it gave me a null pointer exception.
Any strategies to do this replacement in the cleanest way possible?