问题
I am trying to use the Navigation Drawer with my RSS Reader app. Previously I had multiple tabs with ListFragments to display the parsed feeds. I am just using Googles sample at the moment (Found here: http://developer.android.com/training/implementing-navigation/nav-drawer.html) but am running into an issue when trying to use a ListFragment.
private void selectItem(int position) {
// update the main content by replacing fragments
RSSFragment fragment = new RSSFragment();
Bundle args = new Bundle();
args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
fragment.setArguments(args);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
// update selected item and title, then close the drawer
mDrawerList.setItemChecked(position, true);
setTitle(mCategoryTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
}
In this method it tells me that I cannot use the replace method with ListFragments. So what should I be using instead to make this work?
回答1:
It looks like ListFragments cannot be used with the Navigation Drawer. However I was able to convert them to normal Fragments with a ListView and it works just fine.
来源:https://stackoverflow.com/questions/18003065/using-a-listfragment-with-navigation-drawer