0

Which function will be called when the fragment resume.

I have read this question here setTitle when Fragment is visible again , but i must use the add() function. What should i do? onResume function is not called!

EDIT: In MainActivity:

getSupportFragmentManager().beginTransaction().replace(R.id.container,fragmentA).commit();

when click a button in fragment A, the fragment B will be show:

onClick(View v){
    getSupportFragmentManager().beginTransaction().add(R.id.container,fragmentB).commit(); 
}    

And when i press back button, it resume to fragment A, but onResume() function in A is not called.

Community
  • 1
  • 1
Lê Vũ Huy
  • 714
  • 6
  • 16

1 Answers1

0

Since you are adding a fragment, and not replacing it, the onResume() method will not be called for Fragment A. Fragment A did not went to onPause() when you add another fragment to the parent container.

Have a look at the Android deverlopers page: http://developer.android.com/training/basics/fragments/communicating.html#DefineInterface

Malwinder Singh
  • 6,644
  • 14
  • 65
  • 103
  • But when i add fragment B, i cant see fragment A, fragment A is not visible :( I want to know how to handle when fragment B remove and fragment A return. – Lê Vũ Huy Aug 31 '15 at 06:10