android.app.Fragment已过时

今天早上使用Fragment时,忽然发现,android.app.Fragment已经过时了…

/**
 * @deprecated Use the <a href="{@docRoot}tools/extras/support-library.html">Support Library</a>
 *      {@link android.support.v4.app.Fragment} for consistent behavior across all devices
 *      and access to <a href="{@docRoot}topic/libraries/architecture/lifecycle.html">Lifecycle</a>.
 */
@Deprecated
public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListener {}

官方建议使用android.support.v4.app.Fragment来替代.
还有就是:android.app.FragmentManager也是过时了…官方建议使用import android.support.v4.app.FragmentManager;

/**
 * @deprecated Use the <a href="{@docRoot}tools/extras/support-library.html">Support Library</a>
 *      {@link android.support.v4.app.FragmentManager} for consistent behavior across all devices
 *      and access to <a href="{@docRoot}topic/libraries/architecture/lifecycle.html">Lifecycle</a>.
 */
@Deprecated
public abstract class FragmentManager {}
已标记关键词 清除标记
<LinearLayout 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" android:orientation="vertical" android:id="@+id/about" tools:context="com.example.toolbar.MainActivity" > <include layout="@layout/toolbar" /> <android.support.v4.widget.DrawerLayout android:id="@+id/drawer" android:layout_width="match_parent" android:layout_height="match_parent" > <!-- 内容界面 --> <LinearLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <com.example.toolbar.widget.PagerSlidingTabStrip android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="48dip" > </com.example.toolbar.widget.PagerSlidingTabStrip> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" > </android.support.v4.view.ViewPager> </LinearLayout> <!-- 侧滑菜单内容 --> <LinearLayout android:id="@+id/drawer_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="start" android:background="@color/white" android:orientation="vertical"> <com.hyh.circle.CircleImageView android:layout_width="100px" android:layout_height="100px" android:id="@+id/user_display" android:src="@drawable/user_display"/> <ListView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/list"> </ListView> </LinearLayout> </android.support.v4.widget.DrawerLayout> </LinearLayout> 这个是我的主页面布局我想把id为content的LinearLayout替换自己定义的fragment 但是使用fragmentManager.beginTransaction().replace(R.id.content,fragment,"fragment").commit()还是原来的页面
©️2020 CSDN 皮肤主题: 猿与汪的秘密 设计师:上身试试 返回首页