Sunday 15 January 2012

android - GridView behaves weird; duplicates TextView -


So I've found a GridView to display some flags. Each GridView cell contains an ImageView and a TextView. Only the image view is shown in the beginning. When position 1 and 240 in GridView loads, the text view should be visible.

  @ override public view getView (see the status of int, seeviewview, ViewGroup parent) {ViewHolder mVHolder; If (convertView == faucet) {convertView = LayoutInflater.from (mContext) .inflate (R.layout.grid_images, guardian, incorrect); MVHolder = new viewholder (); MVHolder.mImageView = (ImageView) ConvertViewfindVBIID (RIDGridView_IMG); MVHolder.mTextView = (TextView) ConvertViewFindVBIID (R.textas); MVHolder.mTextView.setVisibility (View.INVISIBLE); ConvertView.setTag (mVHolder); } And {mVHolder = (ViewHolder) ConvertView.gettag (); } Int img = Flagcontainer.flags.get (status) .getFlagThumb (); Picasso.with (mContext) .load (img) .into (mVHolder.mImageView); If (position == 1 || condition == 240) {mVHolder.mTextView.setVisibility (see Visual); } Return Convertview; } Class Vendor {ImageView mImageView; TextView mTextView; }  problem:   

When the bottom of the grid is scrolled, the textview of cell 240 is displayed. If someone scrolls, the text views of other cells are displayed compared to 1 and 240.

What's wrong with my code?

Watch the video to visualize the problem

Video:

as el_bhm indicated this bit

  if (position == 1 || position == 240) {mVHolder.mTextView.setVisibility (see Visual.); }   

requires another where mVHolder.mTextView.setVisibility (see GONE);

No comments:

Post a Comment