You are not using convertView
correctly. The views in an adapter are recycled to prevent extra view creations. If the view is recycled it is passed in convertView
. But the important point here is that the view could previously belong to a different item. If you do not fill the view again, it will contain an incorrect data - data that belong to some other item that was recycled.
The getView
method is supposed to contain something like this:
public View getView(int position, View convertView, ViewGroup parent) {
View gridView;
if (convertView == null) {
// create new gridView here
} else {
// recycle the convertView
gridView = (View) convertView;
}
// fill the gridView here
return gridView;
}