In the last Fragment Tutorial I simply showed two fragments in one activity. Today I am going to show you how we can pass the data between two fragments. its pretty easy to pass data between two fragments with the help of interface..

Define Fragments (activity_main.xml):

Create Fisrt Layout (layout_one.xml)

Create Second Layout (layout_second.xml)

Create Interface (OnButtonPressListener.java)

Create LayOutOne (LayOutOne.java)

Create LayOutTwo (LayOutTwo.java)

Create MainActivity (MainActivity.java)

Download Source Code