【发布时间】:2021-09-19 12:36:15
【问题描述】:
你好,我试图在 EditProfile Fragment 中包含一个 backstack,当按下 back 时它会返回到 Profile Fragment 但它会返回到 Home Fragment
如果您想要更多参考代码,请告诉我,我会更新 完整代码的问题
个人资料片段
editProfileButton = relativeLayout.findViewById(R.id.edit_profile_button); // buuton to start editprofile fragment
editProfileButton.setOnClickListener(v -> {
Fragment edit_profile = new Edit_Profile();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, edit_profile);
transaction.addToBackStack(String.valueOf(new Profile_Fragment())); // i thinked this method of implementing string.valueof will navigate back to the given fragment but as you know it is not working
transaction.commit();
});
【问题讨论】:
标签: android fragment-backstack android-fragment-manager