首页 > 解决方案 > 片段无法加载

问题描述

所以我尝试制作一个带有导航抽屉的抽屉,长话短说,在活动中,我试图放入其中的片段不会在运行时加载。我的 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">

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

标签: android-fragments

解决方案


推荐阅读