2

I have a fragment defined in my xml layout and I want to pass data to it from my fragmentactivity. Is that possible ? I don't want to include the fragment at run time because I am not planning to change fragments during the life of the activity. Here is my xml

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <fragment
        android:id="@+id/profileFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        class="com.fragments.MyProfileFragment" >
    </fragment>

    <fragment
        android:id="@+id/hoppiesFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        class="com.fragments.HoppiesFragment" >
    </fragment>
</LinearLayout>
Nayra Ahmed
  • 657
  • 1
  • 9
  • 29

1 Answers1

3

Use FragmentManager#findFragmentById method to get fragment and pass data to some of its public methods.

michal.z
  • 2,025
  • 1
  • 15
  • 10