January 2014
Intermediate to advanced
736 pages
70h 43m
English
Class AddEditFragment overrides Fragment lifecycle methods onAttach and onDetach (Fig. 8.37) to set instance variable listener to refer to the host Activity (line 49) when the AddEditFragment is attached and to set listener to null (line 57) when the AddEditFragment is detached.
44 // set AddEditFragmentListener when Fragment attached45 @Override46 public void onAttach(Activity activity)47 {48 super.onAttach(activity);49 listener = (AddEditFragmentListener) activity;50 }51 52 // remove AddEditFragmentListener when Fragment detached53 @Override54 public void onDetach()55 {56 super.onDetach(); ...
Read now
Unlock full access