android - How to communicate between two child Fragments inside a Nested Fragment -
i can communicate between 2 fragments of activity callback interface. following way, have implemented interface in parentfragment communicate.
but in case of activity, using -
@override public void onattach(activity activity) { super.onattach(activity); try { mcallback = (onheadlineselectedlistener) activity; } catch (classcastexception e) { throw new classcastexception(activity.tostring() + " must implement onheadlineselectedlistener"); } } and in current case, using mcallback = (onheadlineselectedlistener) getparentfragment(); instead of mcallback = (onheadlineselectedlistener) activity;. working well. approach okay? or should thread instead onattach()?
the cast thing ensure object instance of class implements given interface (in case onheadlineselectedlistener). it's irrelevant @ point type of object activity, fragment or else. long implements interface need, fine.
Comments
Post a Comment