我正面临两个问题,即在片段中按下。
第一个问题是,在我的活动中我有主要片段,当我点击按钮时,它将替换另一个片段B.
在B片段中我有三个按钮,点击每个按钮被三个片段替换。片段C,片段D,片段E.
在片段C中我有片段F.在片段F中我点击时有按钮它移动到片段G.
在Fragment G中,我使用PopBackStack()
方法移动到Fragment B.它已成功移动。但是当我点击片段D并且片段D被成功查看时。当我在Fragment D中按下它时,它会移动到Fragment G,然后它会进入Main Fragment。
我需要在片段D中按下后移动片段片段B.
片段C,D,E中的代码
customerSearchLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Fragment_Money_Transfer_Pin fragment = new Fragment_Money_Transfer_Pin();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
});
mtChargesLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Fragment_MoneyTransfer_Charges fragment = new Fragment_MoneyTransfer_Charges();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
});
paymentReports.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle bundle = new Bundle();
bundle.putString("number","0");
Fragment_MoneyTransfer_History fragment = new Fragment_MoneyTransfer_History();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getFragmentManager().beginTransaction();
fragment.setArguments(bundle);
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
});
Fragment G中的反压代码
getFragmentManager().beginTransaction().add(R.id.fragment_container, ldf).commit();
getFragmentManager().popBackStack(Fragment_MoneyTransfer_Home.class.getSimpleName(),
FragmentManager.POP_BACK_STACK_INCLUSIVE);
Fragment_New_Money_Transfer fragment = new Fragment_New_Money_Transfer();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getFragmentManager().beginTransaction();
fragment.setArguments(args);
fragmentTransaction.replace(R.id.fragment_container, fragment);
// fragmentTransaction.addToBackStack( Fragment_Money_Transfer_Mobile.class.getSimpleName() );
fragmentTransaction.commit();
2)我的第二个问题是片段被反压重叠。 请帮我解决这个问题。