GridView of Android, the worst UI control
First, it is a quite some work to use a GridView even for the simplest task. An adapter needs to be created. The mechanism of the adapter is messy, shaky. One would think that GridView.getChildAt(i) would always return the ith child of the GridView. No, it does not if some children are outside the viewable window. It does only if all the children are viewable. It seems no one knows how to get the ith child of a GridView.
The worst is that some elements of a child may be moved to another child. All of the mess probably has to do with the so-called recycled view mechanism of GridView.
GridView should be avoided whenever possible.
If one has to use GridView, pay attention to convertView of getView (int position, View convertView, ViewGroup parent) of the must-have adapter. It must be used if it is not null, otherwise there will be memory leakage. The document says:
"The old view to reuse, if possible. Note: You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view. Heterogeneous lists can specify their number of view types, so that this View is always of the right type (see getViewTypeCount() and getItemViewType(int))."
One cannot get rid of the memory held by convertView even it is assigned null.