【发布时间】:2015-12-14 21:27:03
【问题描述】:
我有一个充满图像的 Gridview,当您单击其中一个图像时,它会启动一个详细活动。
一切正常,但现在我想做一个主从布局。所以我创建了那个“layout-land”文件夹,而不仅仅是一个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>
在此之前,我将详细信息的数据作为 Intent 的 Extra 传递并在 Fragment 中检索它。
但是当我在同一个屏幕上显示所有内容时,如何在不启动新活动的情况下单击图像时以更新详细信息的方式传递数据?谢谢。
【问题讨论】:
-
communicating with other fragments 文档是我发现的最简单的主从片段示例。
标签: android android-fragments android-activity android-fragmentactivity