关于Android Fragment对回退栈的详细理解

  @Override

  public View onCreateView(LayoutInflater inflater, ViewGroup container,

  Bundle savedInstanceState) {

  // Inflate the layout for this fragment

  View mView = inflater.inflate(R.layout.fragment_one, container, false);

  editText = mView.findViewById(R.id.et_input);

  button = mView.findViewById(R.id.btn_next);

  System.out.println("mView.findViewById = "+editText);

  button.setOnClickListener(new View.OnClickListener() {

  @Override

  public void onClick(View v) {

  Fragment fTwo = new FragmentTwo();

  FragmentManager fm = getActivity().getSupportFragmentManager();

  FragmentTransaction tx = fm.beginTransaction();

  tx.replace(R.id.fl_content, fTwo, "TWO");

  tx.addToBackStack(null);

  tx.commit();

  System.out.println( "fm.getBackStackEntryCount() = "+ fm.getBackStackEntryCount());

  }

  });

  return mView;

  }

  @Override

  public void onStop() {

  super.onStop();

  Log.d("Tina======>", "onStop");

  }

  @Override

  public void onDestroyView() {

  super.onDestroyView();

  Log.d("Tina======>", "onDestroyView"+editText);

  }

  @Override

  public void onDetach() {

  super.onDetach();

  Log.d("Tina======>", "onDetach");

  }

  @Override

  public void onDestroy() {

  super.onDestroy();

  Log.d("Tina======>", "onDestroy");

  }