In app activity I have ViewPager
attached to FragmentPagerAdapter
which have three items all of them have list views attached to cursor loaders.
public static class TaskListFragment extends Fragment implements LoaderCallbacks<Cursor> {
public TaskListFragment() {
}
protected static final String excludeCompletedArg = "excludeCompleted";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
...
getLoaderManager().initLoader(filter, cursorArgs, this);
...
}
@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
// TODO Auto-generated method stub
return new CursorLoader(getActivity(),
Uri.parse("content://someurl"),
null,
null,
new String[] { Integer.toString(arg0), arg1.getString(TaskListFragment.excludeCompletedArg) },
null);
}
}
But which way I can force to reload cursor with new bundle argument? For an example I handle onTabReselected
of main activity
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
LoaderManager loaderManager = mSectionsPagerAdapter.getItem(tab.getPosition()).getLoaderManager();
}
thows exception.
I don't want to use FragmentStatePagerAdapter
instead.
Then invoke
TaskListFragment.ReloadCursor(int fragmentIndex)
from parent activity, for example, fromonTabReselected
. It works.Any suggestions for more simple way?