【问题标题】:Add subheaders in GridView在 GridView 中添加子标题
【发布时间】:2013-11-27 12:02:30
【问题描述】:

我想在 GridView 行(不是单元格,而是行)之间添加空行,并且我想在这些空白处添加文本,所以基本上为 GridView 中的部分添加子标题。

类似这样的:

Subheader 1
cell cell cell cell
cell cell cell cell
Subheader 2
cell cell cell cell
cell cell
Subheader 3
cell cell cell cell
cell
.......

找不到这样做的方法。有什么想法吗?

【问题讨论】:

标签: android


【解决方案1】:

Sticky Grid header

这是一个链接 - 您的要求的粘性列表标题,每组网格项目的标题。 试试看。

【讨论】:

    【解决方案2】:

    我认为这可以通过制作自己的布局来实现:

    <ScrollView>
      <LinearLayout android:id="@+id/container">
        <com.project.MyGridView/>
      </LinearLayout>
    </ScrollView>
    

    要添加标题使用类似的东西:

    container.addView(header, 0);
    

    最后你必须扩展 GridView 的高度:

    Class MyGridView extends GridView {
        ....
        @Override
        protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(widthMeasureSpec, MeasureSpec.UNSPECIFIED);
        }
        ....
    }
    

    【讨论】:

      猜你喜欢
      • 2014-11-03
      • 1970-01-01
      • 2011-05-22
      • 2013-03-23
      • 1970-01-01
      • 2010-10-15
      • 2018-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多