打开片段后破坏活动

时间:2017-11-23 15:50:53

标签: java android android-fragments

我正在从活动中打开一个片段。在打开片段时,活动会在片段的背景处添加。这是我如何打开片段

的狙击手
getSupportFragmentManager().beginTransaction()
                                        .add(android.R.id.content, new HomeFragment()).commit();

EDITTED 这是我的家庭片段xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".HomeFragment">

    <!--<TextView-->
        <!--android:layout_width="wrap_content"-->
        <!--android:layout_height="wrap_content"-->
        <!--android:layout_centerInParent="true"-->
        <!--android:text="HOME"-->
        <!--android:textSize="30sp" />-->

    <!--<include layout="@layout/view_image" />-->
    <ListView
        android:id="@+id/lv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

</RelativeLayout>

上述片段从活动中打开。我的挑战是如何在打开片段后销毁活动。

0 个答案:

没有答案
相关问题