我有一個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)文檔是我發現主從片段的最簡單的例子。 –