title: Get data from fragment android
body: <p>I have a little problem with my Android app. I have a layout (RelativeLayout) where I place 2 different fragments, and a button that doesn't belong to any of the fragments. The xml code of the activity layout is something like this</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
  &lt;fragment
      android:id="@+id/fragment1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_marginTop="107dp"
      class="app.fragment1" /&gt;
  &lt;fragment
      android:id="@+id/fragment2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_marginTop="107dp"
      android:layout_below="@+id/fragment1"
      class="app.fragment2" /&gt;
  &lt;Button
      android:id="@+id/btn1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:text="@string/btn1" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>In the first fragment (fragment1) I have six EditText controls, where the user has to enter a number in each of the EditText. My question is how can I access the number that has been entered by the users in the EditText controls on the "OnClickListener" method of the button? (on the activity.java file)</p>