【发布时间】:2020-03-20 06:20:37
【问题描述】:
我在这样的流程中使用多个片段:片段 A 在其项目上有一个列表单击片段 B 打开,它还有一个列表打开片段 C 有一个列表打开另一个活动,问题是当我从另一个Activity返回我发现Fragment A已打开,从另一个Activity返回时如何恢复上一个Fragment C?
这是在我的活动中替换 Fragment 的代码
protected void showFragment(Fragment fragment) {
String TAG = fragment.getClass().getSimpleName();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.container_home, fragment, TAG);
fragmentTransaction.addToBackStack(TAG);
fragmentTransaction.commit();
}
【问题讨论】:
标签: android android-fragments fragment android-listfragment