Multiple Selection in Gallery View
<p>In my Gallery I am setting a background for my TextView simulating Clicking effect.</p>

<p>ie. When i Click on the TextView set the desired background. When I click on other TextView  that TextView gets this background and the previous one gets a Null Background.</p>

<p>What I see is if i scroll through the Gallery and back and then i select some item I get the previous click background persistent along with the new one something Like the Below Image:-</p>

<p><img src="http://i.stack.imgur.com/ApcT0.png" alt=""></p>

<p>Can someone help me with this!</p>

<p>My Code:-</p>

<pre><code>public void MyFunc(){

    Gallery gallery = (Gallery) findViewById(R.id.gallery);
    gallery.setAdapter(new ImageAdapter());
    gallery.setSpacing( 10 );
    gallery.setAnimationDuration( 1000 );
    gallery.setSelection(0,false);
    final View selectedView = gallery.getSelectedView();
    selectedView.setBackgroundDrawable( getResources().getDrawable( R.drawable.gallery_background ) );  
    cposition=0;
    gallery.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {

        View t_lastSelectedTextView = parent.getChildAt(cposition);
        if(t_lastSelectedTextView!=null){
            t_lastSelectedTextView.setBackgroundDrawable( null );
            t_lastSelectedTextView.setBackgroundColor( Color.TRANSPARENT );                                 
        }
        v.setBackgroundDrawable( getResources().getDrawable( R.drawable.gallery_background ));
        cposition=position;
    });
}

 public class ImageAdapter extends BaseAdapter {

      @Override
      public long getItemId(int position) {
           return position;
      }

      @Override
      public View getView(int position, View convertView, ViewGroup parent) {

           TextView mTextView = (TextView)getLayoutInflater().inflate(R.layout.gn_text_view, null);
           mTextView.setText(options[position]);
           mTextView.setLayoutParams(new Gallery.LayoutParams( Gallery.LayoutParams.WRAP_CONTENT,Gallery.LayoutParams.WRAP_CONTENT));

           if(position == cposition){

                mTextView.setBackgroundDrawable( getResources().getDrawable( R.drawable.gallery_background ));

           }

           return mTextView;
      }
 }
</code></pre>
