I am trying to build something similar to the Android Fragments tutorial: I have a ListView fragment on the left and a fragment that can display an item on the right.
Now I am trying to auto-select the first item in the list as soon (or soon after) it has been loaded through the SimpleCursorAdapter (which I use through the LoaderManager)-- all using the Android support library.
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mAdapter = new SimpleCursorAdapter(/* options */);
setListAdapter(mAdapter);
}
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
CursorLoader cl = new CursorLoader(getActivity());
/* setProjection, etc */
return cl;
}
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mAdapter.swapCursor(data);
}
public void onLoaderReset(Loader<Cursor> loader) {
mAdapter.swapCursor(null);
}
I have checked various sample implementations and they all seem to be much too simple or simply don't populate the fragment on the right on load but just upon a click.
I needed to implement a onLoadFinished
anyway but that is too late for me as I am loading a long list. So I was thinking along the lines of an onItemLoadedListener
which I would only use the first time it is called. But nothing like that seems to exist so I am quite stuck.
Thanks for any pointers!