android - Updating Parent Fragment from Child Fragment -


in android application, have 2 fragments. parent fragment contains list of available filter types , when particular filter type clicked (in parent fragment - yellow background) corresponding child fragment (pink background) opens list of available options selected filter type. requirement once user select/deselect option in child fragment, should reflect/update option count (green color) in parent fragment.

please check attached wireframe.

enter image description here

you can use otto bus comunications between fragments, fragments-activities, services, etc.

maybe, first time can little weird if have not used before powerful , easy use. can find library , tutorial here:

http://square.github.io/otto/

an example. in adapter or have item click event cand send object bus.

in bus invoque post method , pass object. (i recommended create singleton bus).

the singleton bus provider.

/**  * canal de comunicacion  */ public class busprovider {      private static final bus rest_bus = new bus(threadenforcer.any);     private static final bus ui_bus = new bus();      private busprovider() {};      public static bus getrestbusinstance() {         return rest_bus;     }      public static bus getuibusinstance () {         return ui_bus;     } } 

you send object in bus (in child fragment) this:

busprovider.getuibusinstance().post(itemselected); 

and in parent fragment subscribe event:

@subscribe public void activityselected(final item itemselected) {  } 

hope helps you!!


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -