在导航抽屉中切换片段时,Android ListView项消失

在导航抽屉中切换片段时,Android ListView项消失,android,listview,android-fragments,navigation-drawer,swiperefreshlayout,Android,Listview,Android Fragments,Navigation Drawer,Swiperefreshlayout,我在使用导航抽屉并在其中显示ListView时遇到问题。当用户单击导航抽屉中的项目时,它会在片段之间切换以显示请求的片段。在一个片段中我有一个ListView,我注意到当我切换到另一个片段并返回到包含ListView的片段时,所有的项目都消失了。我还注意到,SwipeRefreshLayout停止工作。我怎样才能解决这个问题 我正在使用的导航抽屉: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/an

我在使用导航抽屉并在其中显示ListView时遇到问题。当用户单击导航抽屉中的项目时,它会在片段之间切换以显示请求的片段。在一个片段中我有一个ListView,我注意到当我切换到另一个片段并返回到包含ListView的片段时,所有的项目都消失了。我还注意到,SwipeRefreshLayout停止工作。我怎样才能解决这个问题

我正在使用的导航抽屉:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include android:id="@+id/toolbar" layout="@layout/toolbar" />

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/frame_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <ListView
            android:id="@+id/lv_drawer_menu"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:background="#fff"
            android:divider="@null"
            android:dividerHeight="0dp"
            android:drawSelectorOnTop="true"/>

    </android.support.v4.widget.DrawerLayout>

</LinearLayout>

我使用此代码在片段之间切换:

private void setFragment(int position, Class<? extends Fragment> fragmentClass) {
        invalidateOptionsMenu();
        try {
            Fragment fragment = fragmentClass.newInstance();
            FragmentManager fragmentManager = getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.replace(R.id.frame_container, fragment, fragmentClass.getSimpleName());
            fragmentTransaction.commit();

            toolbar.setTitle(fragmentTitles[position]);
            drawerMenu.setItemChecked(position, true);
            drawerLayout.closeDrawer(drawerMenu);
            drawerMenu.invalidateViews();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

private void setFragment(It Point,ClassThis是如此广泛。什么导航抽屉?导航抽屉布局或刚刚推出的新设计。没有代码片段?@ JaredBurrows请查看@编辑的问题代码的片段与ListVIEW将有助于诚实地,如果这是一个新的应用程序,考虑切换到新的API:@ JeRedBurror我想要的。但在github代码中,没有关于按下抽屉项时如何切换片段的示例。