Android:片段backstack

时间:2015-08-04 12:09:20

标签: android android-fragments

ExerciceActivity我展示ExerciceFragment

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ...

        addFragment(ExerciceFragment.newInstance(exerciceId), ExerciceFragment.TAG);
    }

ExerciceFragment开始,我使用EventBus启动另一个片段

库。该事件正在ExerciceActivity中找到:

public void onEvent(ShowExercicePhotosGalleryEvent event) {
        addFragment(ExercicePhotosGalleryFragment.newInstance(event), ExercicePhotosGalleryFragment.TAG);
    }

要从ExerciceFragment backstack弹出Fragment,我就这样做了:

private void exit() {
        FragmentManager fm = getFragmentManager();
        if (fm.getBackStackEntryCount() > 0) {
            fm.popBackStack();
        } else {
            super.onBackPressed();
        }
    }

这里的一切都很完美。在ShowExercicePhotosGalleryEvent我修改了toolbarAppearance(alpha=0)。当我回到ExerciceFragment时,我想恢复我的初始工具栏。那么,当我回到ExerciceFragment时,会调用哪种方法?

谢谢你们!

0 个答案:

没有答案