GridView onTouchListener not working as i expected
<p>pls help with my problem:</p>

<p>i have a gridview and a touchListener on its elements. The problem is when i touch an element i want to change it s background and when the touch is finished(Action up or ouside) to display the initial background. the problem is when i m tapping over an element then drag my finger over another element, the initial element change it s background, but after i drag the finger over another element and finish the touch the background of the first element touched is not changing to the initial background. the idea is that when  i touch down an elemnt from the gridview to get his lock. this is may code:</p>

<pre><code>package com.mines.gui.components; 

import android.content.Context; 
import android.graphics.Bitmap; 
import android.graphics.drawable.BitmapDrawable; 
import android.util.Log; 
import android.view.MotionEvent; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.BaseAdapter; 
import android.widget.GridView; 
import android.widget.ImageView; 

import com.mines.globals.GlobalVariables; 

public class MinesView extends GridView { 

    private int[] length = new int[81]; 
    private final Bitmap grid0 = Bitmap.createBitmap(GlobalVariables.icons, 0, 88, 50, 50); 
    private final Bitmap grid1 = Bitmap.createBitmap(GlobalVariables.icons, 50, 88, 50, 50); 
    private int id; 

    public MinesView(Context context) { 
        super(context); 

        setAdapter(new MineAdapter(context)); 
        setStretchMode(GridView.NO_STRETCH); 
        setNumColumns(9); 
        setHorizontalSpacing(40); 
    } 

    class MineAdapter extends BaseAdapter { 

        private Context context; 

        public MineAdapter(Context context) { 
            this.context = context; 
        } 

        public Object getItem(int position) { 
            return position; 
        } 

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

        public int getCount() { 
            return length.length; 
        } 

        public View getView(int position, View convertView, ViewGroup parent) { 
            final ImageView imageView; 

            if(convertView == null) { 
                imageView = new ImageView(context); 
                imageView.setLayoutParams(new GridView.LayoutParams(40, 40)); 
                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); 
            } else { 
                imageView = (ImageView) convertView; 
            } 
            imageView.setBackgroundDrawable(new BitmapDrawable(grid0)); 
            imageView.setId(position); 

            imageView.setOnTouchListener(new OnTouchListener() { 
                public boolean onTouch(View arg0, MotionEvent arg1) { 

                    switch (arg1.getAction() &amp; MotionEvent.ACTION_MASK) { 
                        case MotionEvent.ACTION_DOWN:  
                        case MotionEvent.ACTION_POINTER_DOWN: 
                            imageView.setBackgroundDrawable(new BitmapDrawable(grid1)); 
                        break; 
                        case MotionEvent.ACTION_OUTSIDE: 
                        case MotionEvent.ACTION_UP:  
                        case MotionEvent.ACTION_POINTER_UP:  
                            imageView.setBackgroundDrawable(new BitmapDrawable(grid0)); 
                        break; 
                    } 
                    return false; 
                } 
            }); 

            imageView.setOnClickListener(new OnClickListener() { 

                public void onClick(View arg0) { 
                    // TODO Auto-generated method stub 

                } 
            }); 

            return imageView; 
        } 

    } 

} 
</code></pre>
