So i got a GridView displaying some flags. Each GridView cell consists of an ImageView and a TextView. Only the ImageView is shown at start. When position 1 and 240 in the GridView loads, the TextView should become visible.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder mVHolder;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.grid_images, parent, false);
mVHolder = new ViewHolder();
mVHolder.mImageView = (ImageView) convertView.findViewById(R.id.gridview_img);
mVHolder.mTextView = (TextView) convertView.findViewById(R.id.textas);
mVHolder.mTextView.setVisibility(View.INVISIBLE);
convertView.setTag(mVHolder);
} else {
mVHolder = (ViewHolder) convertView.getTag();
}
int img = Flagcontainer.flags.get(position).getFlagThumb();
Picasso.with(mContext).load(img).into(mVHolder.mImageView);
if (position == 1 || position == 240) {
mVHolder.mTextView.setVisibility(View.VISIBLE);
}
return convertView;
}
class ViewHolder {
ImageView mImageView;
TextView mTextView;
}
The problem:
When scrolled all the way to the bottom of the GridView, the TextView of cell 240 gets displayed. If one scrolls up, TextViews of other cells than 1 and 240 gets displayed.
What is wrong with my code?
See the video to visualize the problem