Preface
Record A abnormal problem encountered when dynamically replacing Fragment.
StatementWelcome to repost, but please keep the original source of the article :) blog Park: http://www.cnblogs.com
Farmer's uncle: http://over140.cnblogs.com
Body
First look at the Code:
Private void addFragmentToStack (Fragment fragment ){
FragmentTransaction ft = getSupportFragmentManager (). beginTransaction ();
Ft. replace (android. R. id. content, fragment );
Ft. setTransition (FragmentTransaction. TRANSIT_FRAGMENT_FADE); // sets the animation effect
Ft. commit ();
}
After running the command, you will find that the fragment is in full screen (also specified in layout )! You can even remove FrameLayout from the current ContentView!
Cause:
You cannot specify the containerViewId as android. R. id. content. You can change it to R. id. fragment_container.
End
The old method is to comment out the code in one line and download the code that can be run by others. It took a lot of time. Without further research, it may be used for other purposes.