2012-09-28 126 views
-1

在我的android,我有列表和每个列表项目将显示三个GridViews。一个GridView显示所有项目及其详细信息,其次显示有关该列表的一些操作,然后第三个显示注销操作。ANDROID:添加自定义视图到网格视图

是否可以实现?如果是,请为我提供实现的最佳方法....

回答

0

如果要在ListView中添加网格,可以选择GridLayout而不是网格视图。 通过以下xml代码自定义您的listview项目。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/whole_row" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 
    <GridLayout 
     android:id="@+id/one" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:columnCount="3" 
     android:orientation="horizontal" 
> </GridLayout> 
<GridLayout 
     android:id="@+id/two" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:columnCount="3" 
     android:orientation="horizontal" 
> </GridLayout> 
<GridLayout 
     android:id="@+id/three" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:columnCount="3" 
     android:orientation="horizontal" 
> </GridLayout> 
</LinearLayout>