Android Fragment communication

“To allow a Fragment to communicate up to its Activity, you can define an interface in the Fragment class and implement it within the Activity. The Fragment captures the interface implementation during its onAttach() lifecycle method and can then call the Interface methods in order to communicate with the Activity.” :- developer.android.com

Example

activity_main.xml

MainActivity.java

FragmentA.java

fragment_a.xml

FragmentB.java

fragment_b.xml

Communicator Interface

 

OutPut

fragment

ref : https://developer.android.com/training/basics/fragments/communicating.html

1 Like
Author: bm on June 8, 2016
Category: Android

Your comment:

Your Name

Comment:




Last articles