Home > Mobile >  After the jump fragments in the Activity, two pages content appeared at the same time??
After the jump fragments in the Activity, two pages content appeared at the same time??

Time:05-28

turn 1
Android set a button in the activity, the click jumps fragments, but after the jump shows at the same time, two pages content bosses how to settle this problem I!!
 
@ Override
Public void onClick (View v) {
Androidx. Fragments. App. FragmentManager FragmentManager=getSupportFragmentManager ();
Androidx. Fragments. App. FragmentTransaction beginTransaction=fragmentManager. BeginTransaction ();
The switch (v.g etId ()) {
Case R.i d.f rg1:
The d (TAG, "click jump events");
BeginTransaction. Replace (R.i d.m ain_re, new BlankFragment ());
BeginTransaction. AddToBackStack (null);
break;
}
BeginTransaction.com MIT ();
//moveTaskToBack (true);
}


This is MainActivity layout
 
<? The XML version="1.0" encoding="utf-8"?>
XMLNS: app="http://schemas.android.com/apk/res-auto"
XMLNS: tools="http://schemas.android.com/tools"
Android: layout_width="match_parent"
Android: layout_height="match_parent"
Tools: context="MainActivity" & gt;

<frameLayout
The android: id="@ + id/main_re"
Android: layout_width="match_parent"
Android: layout_height="match_parent" & gt;

The android: id="@ + id/frg1"
Android: layout_width="match_parent"
Android: layout_height="wrap_content"
Android: autoLink="all"
Android: text="jump"
Tools: ignore="MissingConstraints"
Tools: layout_editor_absoluteX="248 dp"
Tools: layout_editor_absoluteY="295 dp/& gt;"






This is to run the results


CodePudding user response:

To hide, show again

CodePudding user response:

Fragments attached to the Activity itself, it cannot be called a jump, you just fragments in the Activity of the container, if the container can't cover the Activity all layout, isn't that shows at the same time
  • Related