刚才在开发中注意到一个小小的细节,在这里备注一下:
onCreate方法在Activity和Fragment中的权限修饰符是不一样的哟
在Activity中onCreate的方法的修饰符是protected(受保护的)
在Fragment中的onCreate方法的修饰符是public(公共的)
Activity的FragmentManager负责调用队列中的Fragment的生命周期方法。
添加fragment供FragmentManager管理时,依次调用onAttach、onCreate、onCreateView方法。
以下是Fragment的生命周期
onAttach-->onCreate-->onCreateView-->onViewCreated-->onActivityCreated-->onStart-->onResume-->onPause-->onStop-->onDestroy-->onDestroyView-->onDetach.
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.