title: Why does my CheckedTextView icon jump around to different elements in my GridView?
body: <p>I have a <code>GridView</code> whose elements are based on a <code>FrameLayout</code> containing an <code>ImageView</code> and a <code>CheckedTextView</code>. The xml file for the FrameLayout is as follows:</p>
  
  <pre><code>&lt;FrameLayout
  xmlns:android = "http://schemas.android.com/apk/res/android"
  android:id="@+id/gridImage"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:gravity="center_horizontal"&gt;
  &lt;ImageView
  android:id="@+id/image"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:adjustViewBounds="false"&gt;
  &lt;/ImageView&gt;
  &lt;CheckedTextView
  android:id="@+id/imageTick"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:gravity="center_horizontal"
  android:layout_gravity="center_horizontal|bottom"
  android:checkMark="@drawable/icon"
  android:checked="false"
  android:visibility="invisible"
  &gt;
  &lt;/CheckedTextView&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>EDIT: This is the adapter's <code>getView()</code> method i use for each element:</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
          Log.d("getView()", position+"");
          View v;
          ImageView imageView;
          if(convertView == null) {
  
              v = LayoutInflater.from(mContext).inflate(R.layout.photo_text_view, null);
              v.setLayoutParams(new GridView.LayoutParams(100,100));
          }
          else
          {
              v = convertView;
  
          }
          imageView = (ImageView) v.findViewById(R.id.image);
          imageView.setImageBitmap(mThumbsIds.get().get(position));
  
          v.setPadding(8, 8, 8, 8);
          return v;
      }
  </code></pre>
  
  <p>In my activity class, I load a context menu and once i select an option i make the <code>CheckedTextView</code> visible for that <code>GridView</code> element like so :</p>
  
  <pre><code>GridView gridView = (GridView) findViewById(R.id.gridview);
      View selected =gridView.getChildAt(position);
      CheckedTextView selectedCheck = (CheckedTextView)selected.findViewById(R.id.imageTick);
      selectedCheck.setChecked(true);
      selectedCheck.setVisibility(View.VISIBLE);
  </code></pre>
  
  <p>So two things can potentially happen from this point:</p>
  
  <p>1) Lets say I picked the element at position 0, the CheckedTextView becomes visible, but when i scroll down my GridView, another element (e.g. position 17) has its CheckedTextView visible aswell. This continues on random elements as i scroll down towards the bottom.</p>
  
  <p>2) If i pick an element towards the bottom, scroll back up to the top, and run one of methods to make all CheckedTextView's invisible, a <code>NullPointerException</code> is thrown for the element at the bottom. This happens at this point: <code>View selected =gridView.getChildAt(position);</code> where selected becomes null.</p>
  
  <p>Whats going on here? Why do these random CheckedTextView's become visible and why do i get exceptions?</p>