Android: Communication between Fragment and another Fragment directly on top of it -


as understand, if want communicate between 2 fragments, on underlying activity. however, 2 fragments not on same hierarchy level, because 1 fragment gets opened within/on top of fragment.

if click button on overlaying fragment, there way communicate directly holding fragment, without going detour on activity? because messy.

a button click on fragment 1 opens fragment 2 in framelayout in fragment 1. sounds big detour send fragment 2 interaction underlying activity , fragment 1.

if understand correctly, mlistener activity, not fragment holds 2nd fragment

 @override public void onattach(context context) {     super.onattach(context);     if (context instanceof onfragmentinteractionlistener) {         mlistener = (onfragmentinteractionlistener) context;     } else {         throw new runtimeexception(context.tostring()                 + " must implement onfragmentinteractionlistener");     } } 

personally, i'd send through activity. but, use message bus instead.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -