我有一个GridView充满了图像,当你点击其中一个图像时,它开始了一个detais活动。
这一切工作正常,但现在我想做一个主 - 布局布局。所以,我创建了“布局,土地”文件夹,而不是只有一个gridview,它是这样的:如何在屏幕上显示的两个片段之间传递数据?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
tools:context=".MainActivityFragment">
<GridView
android:id="@+id/main_grid"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:numColumns="auto_fit" />
<fragment
android:id="@+id/fragment"
android:name="com.example.lucas.popularmovies.DetailActivityFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
tools:layout="@layout/fragment_detail" />
</LinearLayout>
在此之前,我经过详细信息的数据作为额外的意图和检索它片段。
但是,当我在同一个屏幕上显示所有内容时,如何在不启动新活动的情况下单击图像时以更新详细信息的方式传递数据?谢谢。
的[与其它片段进行通信(http://developer.android.com/training/basics/fragments/communicating.html)文档是我发现主从片段的最简单的例子。 –