1、Activity的生命周期
参考以下链接:
https://blog.csdn.net/weixin_34289744/article/details/92609206
2、Fragment的生命周期
参考以下链接:
https://blog.csdn.net/zjclugger/article/details/10442335
这里我们不需要对比、单纯查看fragment的话,把代码修改为:
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fragment f=new ‘所需查看的fragment名称的方法,如:Fragment_Order();‘ Log.e("HJJ", "Activity &&&& onCreate..."); // Create the list fragment and add it as our sole content. if (getFragmentManager().findFragmentById(android.R.id.content) == null) { getFragmentManager().beginTransaction().add(android.R.id.content, f).commit(); } } @Override protected void onStart() { // TODO Auto-generated method stub super.onStart(); Log.e("HJJ", "Activity &&&& onStart..."); } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); Log.e("HJJ", "Activity &&&& onResume..."); } @Override protected void onStop() { // TODO Auto-generated method stub super.onStop(); Log.e("HJJ", "Activity &&&& onStop..."); } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); Log.e("HJJ", "Activity &&&& onPause..."); } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); Log.e("HJJ", "Activity &&&& onDestroy..."); }
所以相对于链接里的输出内容,没有ArrayListFragment的相关输出。
3、对比:
其实上述第二点链接也有讲,这里再推荐一个带有总结的:
https://www.jianshu.com/p/8cbbcc1e2e06
原文:https://www.cnblogs.com/jancy2265/p/13059851.html