-->

使用带有抽屉式导航栏一ListFragment(Using a ListFragment with

2019-10-30 08:09发布

我试图使用导航抽屉与我的RSS阅读器应用程序。 以前我有多个选项卡与ListFragments显示解析饲料。 我只是用谷歌样本的时刻(这里找到: http://developer.android.com/training/implementing-navigation/nav-drawer.html ),而是试图用一个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);
}

在这种方法中它告诉我,我不能使用ListFragments的替代方法。 所以,我应该怎么使用,而不是使这项工作?

Answer 1:

它看起来像ListFragments不能与抽屉式导航使用。 不过我可以将它们转换为正常的片段与ListView和它工作得很好。



文章来源: Using a ListFragment with Navigation Drawer