Fragment生命周期及add、replace、remove、hide&show方法分析
转载自https://blog.csdn.net/u014699958/article/details/52996143 项目有一个Activity类和3个Fragment类。Activity 中放置3个按钮(实质TextView)可以切换到不同的Fragment上。下面将给出Activity 和Fragment的代码和layout。 1-1 Fragment1 public class Fragment1 extends Fragment { final String TAG = " test Fragment1"; public Fragment1() { // Required empty public constructor } @Override public void onAttach(Context context) { super.onAttach(context); Log.d(TAG,"onAttach"); } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG,"onCreate"); } @Override public View onCreateView