I'm trying to make a ListFragment that will periodically be updated (Calls to update not shown here, but the update function is). Here's the log cat that I'm seeing:
04-05 11:05:44.252: V/QslLogFrag(2690): onCreate()
04-05 11:05:44.256: V/QslLogFrag(2690): onCreateView()
04-05 11:05:44.304: V/QslLogFrag(2690): onActivityCreate()
04-05 11:05:44.612: V/QslLogFrag(2690): null
04-05 11:05:44.736: V/QslLogFrag(2690): com.kd7uiy.qslmapper.QslLogAdapter@5282f55c
04-05 11:05:47.948: V/QslLogFrag(2690): null
The last 3 lines lines are all provided in the updateView
class, which is called externally when there's new data to check. The first two are called essentially automatically, the third one is called by user input.
And the code:
public class QslLogFragment extends ListFragment {
private CursorAdapter mAdapter;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getListView().setFastScrollEnabled(true);
Cursor cursor = QslDatabase.getInstance(getActivity()).getTableQuery(
mFilters);
mAdapter= new QslLogAdapter(getActivity(), cursor, 0);
setListAdapter(mAdapter);
Log.v(TAG,"onActivityCreate()");
}
public void updateView() {
Cursor cursor = QslDatabase.getInstance(getActivity()).getTableQuery(
mFilters);
Log.v(TAG,""+getListAdapter());
if (getListAdapter() != null) {
((CursorAdapter) getListAdapter()).changeCursor(cursor);
}
}
Somehow it seems to me as if the adapter is getting set to null. Note I can still scroll through the ListView without problems, but I can't update it, with a new set of filters. Any ideas what's happening?
Note, QslAdapter extends CursorAdapter, and I'm using the Support Library CursorAdapter.
Here's a list of things I've tried:
- I have tried just using
setListAdapter
andgetListAdapter
. - I have tried not using
getListAdapter
, but just keeping a reference tomAdapter
. - I have verified that there is only one instance of this Fragment.
- I am not calling
setListAdapter
anywhere. - I've verified that
getListAdapter
andmAdapter
always report the same pointer, or null.