Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a GridView have a footer and header just like ListView?

A quick question:

In ListView I use this code:

list.addHeaderView(headerView); 

How to deal with it when working on gridview?

Thanks.

like image 645
necixy Avatar asked Apr 26 '11 12:04

necixy


People also ask

Is GridView deprecated?

Both GridView and GridLayout are safe for use in production code. They are obsolete, and I would not recommend that anyone use them, but they are safe. You are contradicting yourself. First you say GridView and GridLayout are not deprecated, then you say they are both obsolete, but safe.

What is the difference between GridView and GridLayout?

GridView simply gives us a two-dimensional view to display the items on the screen, under ViewGroup. On the other hand, GridLayout is a layout manager that arranges the views in a grid.

What is the difference between a Textview and a GridView?

The only difference is that GridView is used to display grid of View objects. The view objects can be a Text view, an Image view or a view group which has both an image and some text. Best example for this view is phone gallery which shows images in a grid.


2 Answers

There is no support for header or footer views with GridView, sorry.

like image 172
CommonsWare Avatar answered Sep 21 '22 21:09

CommonsWare


There is a quite good implementation of GridView with header support in Google Photos application, as it's OSS code you can use it as is or take it as a reference for your own implementation: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.3_r2.1/com/android/photos/views/HeaderGridView.java

Basic idea is quite simple - WrapperAdapter creates an fake row by increasing number of items by number of columns and then return a header view for the item.

like image 33
AlexM Avatar answered Sep 23 '22 21:09

AlexM