是否可以创建具有不同大小子节点的GridView?

时间:2010-12-13 23:58:31

标签: android

所以让我们试着解释一下我要做的事情......

我的设计看起来像这样 -

![alt text] [1]

为此,我创建了两个GridView,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content">

    <LinearLayout android:orientation="vertical"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content">

        <TextView style="@style/GroupName"
                  android:text="@string/currency_badges"/>

        <GridView android:id="@+id/currency_grid"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:columnWidth="90dp"
                  android:numColumns="auto_fit"
                  android:verticalSpacing="10dp"
                  android:horizontalSpacing="10dp"
                  android:stretchMode="columnWidth"
                  android:gravity="left"/>

    </LinearLayout>

    <LinearLayout android:orientation="vertical"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content">

        <TextView style="@style/GroupName"
                  android:text="@string/foursquare_badges"/>

        <GridView android:id="@+id/foursquare_grid"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:columnWidth="90dp"
                  android:numColumns="auto_fit"
                  android:verticalSpacing="10dp"
                  android:horizontalSpacing="10dp"
                  android:stretchMode="columnWidth"
                  android:gravity="left"/>

    </LinearLayout>
</LinearLayout>

我对它并不满意,因为你可以看到右上方图标的标签是隐藏的。我可以点击并滚动,但这不是我想要的。更大的问题是每个 GridView都有自己的滚动条。再也不是我想要的。所以我想我想用一个GridView来完成这个任务。如何使用GridView来显示图标,然后在图标中间显示GroupName。我知道我可以创建一个BaseAdapter来返回不同类型的视图,但我需要有一个项目可以横向占用整个空间。这可能吗?

修改

我想更好的问题是如何创建分组的GridView?

1 个答案:

答案 0 :(得分:0)

我不确定您现在是如何添加项目的,但您可能会考虑使用SimpleAdapter。它允许您提供xml布局并将数据对象中的项映射到xml布局中的位置。如果您进行快速搜索,可以使用许多教程。