咸糖记录编程的地方

Do what you love and the money will follow.

目录
安卓源码学习笔记
/  

安卓源码学习笔记

安卓fragment源码全解析

创建fragment

BlankFragment b = new  BlankFragment();
                android.app.FragmentManager fm = getFragmentManager();
                FragmentTransaction ft=fm.beginTransaction();
                ft.replace(R.id.rootView,b);
                 ft.commit();

返回一个FragmentManager实例

/**
     * Return the FragmentManager for interacting with fragments associated
     * with this activity.
     */
    public FragmentManager getFragmentManager() {
        return mFragments.getFragmentManager();
    }

mFragmentcreateController创建的一个对象

final FragmentController mFragments = FragmentController.createController(new HostCallbacks());

可以看出hostCallBackFragmentHostCallback的子类

private final FragmentHostCallback<?> mHost;

    /**
     * Returns a {@link FragmentController}.
     */
    public static final FragmentController createController(FragmentHostCallback<?> callbacks) {
        return new FragmentController(callbacks);
    }

    private FragmentController(FragmentHostCallback<?> callbacks) {
        //FragmentController的构造函数是
        mHost = callbacks;
    }

标题:安卓源码学习笔记
作者:xiantang
地址:http://xiantang.info/articles/2019/06/03/1559551154117.html

评论