如何将headerview放入gridview中
我必须将标题视图放在网格视图的顶部,例如列表视图。尽管我知道它不支持这一点。但有没有什么办法可以拥有呢。只是想知道是否有人做过这方面的工作?
I have to put header view on top of grid view like list view. Although I know it doesn't have support for that. But is there any way to have it. Just wanted to know if anyone has done work on it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你总是有一个解决方法,比如为页眉和页脚使用 textview,
在 listview 的情况下将 gridview 放在中间,答案将是这样的:
你当然可以在 ListView 周围放置任意元素。例如,您可以定义一个包含两个 TextView 和它们之间的 ListView 的布局。如果这样做,则必须将 id“@android:id/list”分配给 ListView,因为 ListActivity 会搜索具有此 id 的视图。如果执行此操作,则一个 TextView 将始终在 List(标题)上方可见,而另一个 TextView 将在 ListView 下方可见。如果您只想在看到列表的开头/结尾时显示页眉/页脚视图,您可以使用 view.setHeaderView() 或 view.setFooterView()。例如:
对于 gridview 的情况,您需要做自己的布局
- 顶部的文本视图
-gridview
-textview 在底部,它的概念是相同的,
你只是不必说 listView.addHeaderView(header);
因为你会通过布局上的设计来实现这种效果
You always have a workaround like having textview for header and footer with gridview in between
in case of listview the answer will be like this :
You can of course put arbitray elements around your ListView. For example you can define a layout with two TextViews and a ListView between them. If you do this, you must assign the id "@android:id/list" to the ListView, as the ListActivity searches for a view with this id. If you do this then one TextView will always be visible above the List (header) and the other will be visible below the ListView. If you want to display the header / footer view only if see the beginning / end of the list you can use view.setHeaderView() or view.setFooterView(). For example:
for case of gridview you need to do your own layout that will have
-textview on the top
-gridview
-textview on the bottom and that it the concept is the same
you just do not have to say listView.addHeaderView(header);
cause you will make that effect with the design on the layout