今天做项目发现用新的Fragment替换旧的Fragment时发现之前被替换的Fragment组件仍旧显示在那里
xml布局代码如下:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fl_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/shenhefragment"
android:name="com.mip.biz.auth.activity.ShenHeFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<!-- bottom -->
将上述xml布局代码改为如下,问题就解决了
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fl_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/shenhefragment"
android:name="com.mip.biz.auth.activity.ShenHeFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<!-- bottom -->