Android fragments 碎片赢了';t载荷

Android fragments 碎片赢了';t载荷,android-fragments,Android Fragments,所以我试着制作一个带有导航抽屉的抽屉,长话短说,在活动中,我试着放在里面的片段不会在运行时加载。my navdraweractivity.class中的片段代码如下所示: Fragment fragment = new startingfragment(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(R.id.content_frame, frag

所以我试着制作一个带有导航抽屉的抽屉,长话短说,在活动中,我试着放在里面的片段不会在运行时加载。my navdraweractivity.class中的片段代码如下所示:

Fragment fragment = new startingfragment();
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(R.id.content_frame, fragment);
        ft.commit()
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".startingfragment">
我的片段布局的一部分如下所示:
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".startingfragment">

任何可能的原因以及任何可能的解决方案?

打开活动时,是否希望默认加载抽屉选项卡?内容框架是框架布局吗?在你的代码中,一切都很好,你需要发布更多关于抽屉布局和活动布局的代码NVM,我已经解决了:-)