Fragment中调用getActivity为null的问题---------------->Activity与Fragment的调用关系

一,参考:
(1)Fragment中调用getActivity为null的问题
https://blog.csdn.net/goodlixueyong/article/details/48715661

二,定义
1.Fragment
A Fragment is a piece of an application’s user interface or behavior
that can be placed in an Activity. Interaction with fragments it done through
FragmentManager, which can be obtained via Activity#getFragmentManager()
and Fragment#getFragmentManager()

While the Fragment API was introduced in HONEYCOME(android API 11), a version of the API
at is also available for use on older platforms through android.support.v4.app.FragmentActivity.

三,问题
0,Activity和Fragment的关系
A Fragment is closely

  • tied to the Activity it is in, and can not be used apart from one. Though
  • Fragment defines its own lifecycle, that lifecycle is dependent on its
  • activity: if the activity is stopped, no fragments inside of it can be
  • started; when the activity is destroyed, all fragments will be destroyed.

1.Activity如何创建?

2.Fragment如何创建?

3.Fragment如何与Activity关联?

4.Activity的savedInstanceState如何产生,存了什么,如何使用?

5.FragmentManager的作用?

你可能感兴趣的:(Android开发)