1. 程式人生 > >android.app.Fragment已過時

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 {}