使用带有导航抽屉ListFragment [英] Using a ListFragment with Navigation Drawer

查看:197
本文介绍了使用带有导航抽屉ListFragment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用导航抽屉与我的R​​SS阅读器应用程序。 previously我有多个选项卡与ListFragments显示解析饲料。我只是用谷歌样本的时刻(这里找到:的http:// developer.android.com/training/implementing-navigation/nav-drawer.html ),但试图用一个ListFragment当我遇到了一个问题。

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);
}

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

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?

推荐答案

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

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.

这篇关于使用带有导航抽屉ListFragment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆