Android的GridView控件添加页眉和页脚像列表视图 [英] Android GridView add header and footer like listview

查看:287
本文介绍了Android的GridView控件添加页眉和页脚像列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许你想叫 addHeaderView() addFooterView()的GridView ,它没有。

Maybe you want to call addHeaderView() or addFooterView() in GridView, which it does not have.

这是我们要添加标题视图或页脚视图到的GridView 性质。也许你一直在寻找了很长时间和我一样,但最后还是没有找到解决办法。

It's nature that we want to add header view or a footer view to a GridView. Maybe your have been searching a long time like me, but finally find no solution.

在这里,我会给出一个解决方案。

Here, I will give out an solution.

推荐答案

我张贴这个答案只是想谁的人来这里能得到什么想要的。

I post this answer just want people who come here can get what the want.

截屏

GridViewWithHeaderAndFooter gridView = (GridViewWithHeaderAndFooter) v.findViewById(R.id.ly_image_list_grid);

LayoutInflater layoutInflater = LayoutInflater.from(this);
View headerView = layoutInflater.inflate(R.layout.test_header_view, null);
View footerView = layoutInflater.inflate(R.layout.test_footer_view, null);
gridView.addHeaderView(headerView);
gridView.addFooterView(footerView);

https://github.com/liaohuqiu:

It'a单个文件的项目,现在它在 GitHub可以托管/ Android的GridViewWithHeaderAndFooter

It'a single file project, now it hosts at GitHub: https://github.com/liaohuqiu/android-GridViewWithHeaderAndFooter

您可以按照上面的链接来访问code。快乐编码。

You can follow the link above to access the code. Happy coding.

这篇关于Android的GridView控件添加页眉和页脚像列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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