Thiru
Thiru

Reputation: 341

Any similar function for fragment like onActivityResult()

In my application I have scenario like, When user click a button in FragmentA, it will show FragmentB. And when a button clicked on FragmentB it will go to FragmentC.

While navigating from A->B->C, I will set my activity title respectively as "A", "B" & "C". This flow I did using,

public class FragmentC
   onCreateView(){
      mTxtHeaderTitle.setText(getString(R.string.fragC));
   } 
}

Now the question is, how I can set the title bar to "C" while user presses backkey and navigate back to B, ( C -> B )?

Is there any method callback available to do this?

onFragmentResult() as like onActivityResult() in Activity?

Please help.

Upvotes: 1

Views: 711

Answers (1)

andro
andro

Reputation: 977

You can use the onResume() callback method of Fragment to set the title.

onResume() is called by the system whenever the Fragment is in focus and interacting with the user.

Upvotes: 1

Related Questions