Having Trouble Passing Object Between Fragments
I have been spending my time for several days with this question and getting same error. I have been trying to pass object between fragments which are held in action bar. Please te
Solution 1:
In onAttach() function of the first fragment, I have some doubt about initializing the callback menuItemListener. The onAttach() function is called at the very first in the order of sequence of calls to initialize a fragment. getActivity() may not be ready yet to return the associated activity.
Why don't you just initialize like this:
@OverridepublicvoidonAttach(Activity activity) {
// TODO Auto-generated method stubsuper.onAttach(activity);
menuItemListener = (OnMenuItemPressListener) activity;
}
activity itself is available in the parameter of the function. No need to call another function to get it.
Post a Comment for "Having Trouble Passing Object Between Fragments"