Android General Question
<p>I have a small program where i have 2 images, right now i am doing OnTouch events for each image when clicked the image on top is set to invisible. This is working fine.. but having this in the main Activity is getting messy..</p>

<p>I created a TestView, I would like to move the code I have in the main activity to the testView, but I do not know where to put the OnTouch events and how to do the same from there?, I dont know where to put the OnTouch events and also how to draw the ImageViews from my testView.. when I was in the Main activity they drew fine.. but now.. i dont know how to draw them from the "testView extends View" class... can you help me organize it?</p>

<pre><code>public class TestView extends View{


    public TestView(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }
    public TestView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        // TODO Auto-generated constructor stub
    }

    public TestView(Context context) {
        super(context);
                // TODO Auto-generated constructor stub
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas); 


    } 
</code></pre>

<p>}</p>

<pre><code>public class GameActivity extends Activity {    
/** Called when the activity is first created. */
public int ColorId;
public boolean isUserTurn = false;
public int globalIndex = 1;
@Override  
public void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);
    setContentView(R.layout.myviewlay);

final ImageView image1= (ImageView)findViewById(R.id.ImageView03); 
image1.setOnTouchListener(new OnTouchListener()
    {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        // TODO Auto-generated method stub

        try {
            Thread.sleep(200);
         ColorId = 1;
        int action = event.getAction(); 

        if(action == MotionEvent.ACTION_DOWN){             

            image1.setVisibility(View.INVISIBLE);    

            }
        else
        {

            image1.setVisibility(View.VISIBLE);     
        }
        //return super.onTouchEvent(event);   
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return true;
        } 


        }); 
final ImageView image2= (ImageView)findViewById(R.id.ImageView02); 
image2.setOnTouchListener(new OnTouchListener()
    {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        // TODO Auto-generated method stub

        try {
            Thread.sleep(200);
             ColorId = 2;
        int action = event.getAction();         
        if(action == MotionEvent.ACTION_DOWN){             

            image2.setVisibility(View.INVISIBLE);         
            }
        else
        {            
            image2.setVisibility(View.VISIBLE);     
        }
        //return super.onTouchEvent(event);  
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
        return true;
        } 

        });
</code></pre>

<p>I just want to know, if i move it to the test view, how can i re organize it so that it works from there. I am very new to Android... </p>

<p>Thank you</p>
