So I have my MainDisplayActivity
which implements both Activity
and LoaderManager.LoaderCallbacks
. Here I have A L
You just need to move your code around a little and call restartLoader
. That is,
When the user clicks a list item, you somehow change the private instance variable that is returned in getChosenDate()
(I am being intentionally vague here because you didn't specify what exactly getChosenDate()
returns).
Once the change is made, call getLoaderManager().restartLoader()
on your Loader
. Your old data will be discarded and restartLoader
will trigger onCreateLoader
to be called again. This time around, getChosenDate()
will return a different value (depending on the list item that was clicked) and that should do it. Your onCreateLoader
implementation should look something like this:
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
Uri baseUri = SmartCalProvider.CONTENT_URI;
makeProviderBundle(
new String[] { "_id, event_name, start_date, start_time, end_date, end_time, location" },
"date(?) >= start_date and date(?) <= end_date",
new String[]{ getChosenDate(), getChosenDate() },
null);
return new CursorLoader(
this,
baseUri,
args.getStringArray("projection"),
args.getString("selection"),
args.getStringArray("selectionArgs"),
args.getBoolean("sortOrder") ? args.getString("sortOrder") : null);
}
Let me know if that makes sense. :)