Which method is being called after popBackStack?

前端 未结 6 578
误落风尘
误落风尘 2020-12-29 04:13

I have an activity where I am calling three fragments - each depending on each other:

A(ctivity) -> f1 (Fragment one, title {is|should}: list) -> f2 (Fragment two,

6条回答
  •  清歌不尽
    2020-12-29 04:55

    My workaround is to get the current title of the actionbar in the Fragment before setting it to the new title. This way, once the Fragment is popped, I can change back to that title.

    @Override
    public void onResume() {
        super.onResume();
        // Get/Backup current title
        mTitle = ((ActionBarActivity) getActivity()).getSupportActionBar()
                .getTitle();
        // Set new title
        ((ActionBarActivity) getActivity()).getSupportActionBar()
            .setTitle(R.string.this_fragment_title);
    }
    
    @Override
    public void onDestroy() {
        // Set title back
        ((ActionBarActivity) getActivity()).getSupportActionBar()
            .setTitle(mTitle);
    
        super.onDestroy();
    }
    

提交回复
热议问题