I'm new to Andoid, and I created a fragment to replace the fragments programmatically.
I followed the guidance of Android developers.
I created a method called selectFrag and launched it by clicking a button:
public void selectFrag(View view) { Fragment fr; if(view == findViewById(R.id.showsecond)) { fr = new secondfragment(); } else { fr = new firstfragment(); } FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.fragment_place,fr); ft.addToBackStack(null); ft.commit(); }
The code works fine, and I understand everything except addToBackStack(null) .
I experimented and realized that this method consists in adding a fragment to the stack of the feedback button, so if we press the back button, it will not leave the screen and will not show the previous work.
But I do not understand what null shows here. I searched on the Internet, but I knew it was a TAG , and we could use something like this .
So my question is very simple: What does null mean here? or what does null do?
(sorry for my bad english.)
android android-layout android-fragments
xyz
source share