我在xml布局中定义了一个片段,我想从片段活动中将数据传递给它。那可能吗 ?我不想在运行时包含片段,因为我不打算在活动期间更改片段。 这是我的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>
答案 0 :(得分:3)
使用FragmentManager#findFragmentById
方法获取片段并将数据传递给它的一些公共方法。