2012-07-30 39 views
0

我們正在開發,在一個點上,我們需要像蜂窩Gmail應用程序的屏幕應用程序:蜂巢狀觀與片段和ListView

http://www.cnx-software.com/wp-content/uploads/2011/02/android_3.0_honeycomb_gmail_app_fragments_700px.png

我們正在嘗試使用碎片,包括列表視圖顯示我們的項目。 我們做同樣的事情此鏈接:http://www.vogella.com/articles/Android/article.html#fragments_tutorial

但是以任何方式我們沒能看到不同的佈局, 我的意思是,我們可以顯示在右側片段一個TextView的唯一。 但我們需要一個listview,我們可以查看縮略圖,一些解釋,這需要點擊。

有人幫忙嗎?

+0

你應該看看自定義適配器。你想要做的是使用自定義適配器而不是標準即插即用適配器進行列表視圖。 – Warpzit 2012-07-30 13:04:53

+0

我們已經使用自定義適配器和ListFragment來代替單個Activity或Fragment,但即使我們使用了setListAdapter(myAdapter),我們也無法在片段中看到我們的佈局。 – nhr 2012-07-30 13:35:03

回答

0

應該工作。我想你想實例化一個ListFragment,當用戶選擇一行時,實例化另一個ListFragment。

0

也許閱讀this文章。

下面是一個佈局xml文件的示例,它具有兩個彼此相鄰的片段,寬度均勻。

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    > 
    <fragment 
     class="package.of.fragmentA" 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:layout_height="match_parent" 
     android:id="@+id/fragmentA" 
     /> 
    <fragment 
     class="package.of.fragmentB" 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:layout_height="match_parent" 
     android:id="@+id/fragmentB" 
     /> 
</LinearLayout> 

在Gmail應用程序的類fragmentA將是一個ListFragment和fragmentB將是一個正常的片段類與自定義佈局文件的情況下。

+0

我們按照你的說法做了,但是,即使我們不是使用listview,而是使用了一個按鈕,但我們仍然無法查看它。是否有我們錯過的東西,比如提交listview或將其添加到其他函數中? – nhr 2012-07-30 13:36:32