带适配器回收细胞的android gridview的头解决方案 [英] android gridview header solution with adapter recycling cells

查看:167
本文介绍了带适配器回收细胞的android gridview的头解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了有关如何实现一个gridview头,随着电网的其余部分滚动许多解决方案。

I've seen many solutions about how to implement a gridview header that scrolls along with the rest of the grid.

他们中的大多数存在于创造一个listlayout或RelativeLayout的一个头视图和GridView控件的所有内部的滚动视图。该解决方案具有滚动视图不知道网格的大小,以便克服你需要扩展网格视图喜欢这里的问题: http://stackoverflow.com/a/4536955/751180

Most of them consist in creating a listlayout or relativelayout with a header view and a gridview all inside a scrollview. This solution has the problem that the scrollview doesn't know the size of the grid so to overcome that you need to extend grid view like here: http://stackoverflow.com/a/4536955/751180

但问题是,但这样做你迫使GridView控件来呈现所有项目的一次,而无需重复它的细胞。这可能会导致该应用因大量内存的使用特别是如果该意见包含图像的崩溃。

But the problem is that but doing so you are forcing the gridview to render all the items at once without recycling its cells. This will probably cause the app to crash due to heavy memory usage specially if the views contain images.

的其他人正在使用列表视图以及计算多少列可以根据屏幕大小被放置。我个人希望继续使用网格视图。

Other people are using Listviews and calculating how many columns can be placed depending on the screen size. I personally would like to continue using a grid view.

有没有人来实现用不同的方法一个gridview头?

Has anyone ever implemented a gridview header using a different approach?

推荐答案

我已经花了很多时间试图设置正确的头GridView控件。没有sucess。看来,是实现自定义的GridView(从ListView的继承)是唯一合理的途径。这里就是这样的GridView与页眉和页脚的例子: https://github.com/SergeyBurish/HFGridView

I've spend a lot of time trying to set correct header to GridView. No sucess. It seems, that implementing custom GridView (inherited from ListView) is the only reasonable way. Here is an example of such GridView with headers and footers: https://github.com/SergeyBurish/HFGridView

这篇关于带适配器回收细胞的android gridview的头解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆