I use a LoaderManager
to fill the Adapter of my ListView
with data. I implemented the LoaderManager.Callbacks
but I can't refresh the ListView
to display the new data.
Calling adapter.notifyDatasetChanged()
, invalidate()
or postInvalidate()
does nothing.
Some code:
@Override
public void onLoadFinished(Loader<ArrayList<Items>> arrayListLoader, ArrayList<Items> entries) {
Log.i("TAG", "+++ onLoadFinished() called! +++");
switch (arrayListLoader.getId()) {
case LOADER_ID:
mAdapter.setData(entries);
mAdapter.notifyDataSetChanged();
invalidate();
break;
}
}
The adapter
is initialized in the default constructor of the ListView
class.
Adapter and ListView initialization (stripped down to relevant parts):
public CustomListView(Activity activity) {
[...]
mAdapter = new CustomEntryAdapter(mActivity, R.layout.row_monthlistview);
setAdapter(mAdapter);
mCallbacks = this;
LoaderManager loaderManager = mActivity.getSupportLoaderManager();
loaderManager.initLoader(LOADER_ID, null, mCallbacks);
[...]
}
The setData
method of my custom Adapter
:
public void setData(ArrayList<Items> data) {
clear();
if (data != null) {
for (Items aData : data) {
add(aData);
}
}
}
Seems to be impossible in my specific case. The LoaderManager
is the root of the issue, I can't bind n LoaderManager
to n views
.
lim n -> ∞