Attaching event listeners to an android UI componenet?
<p>android 3.0 API Level 11</p>

<p>How do I attach an onTouch Event to the button?</p>

<p>TestDebugingActivity.java</p>

<pre><code>package com.example.debuggingTest;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.*;

public class TestDebugingActivity extends Activity {


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    TextView tv = (TextView)findViewById(R.id.textView1);
    tv.setOnTouchListener((OnTouchListener) this);


    setContentView(R.layout.linear);
  }


}
</code></pre>

<p>linear.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" &gt;



&lt;TextView
    android:id="@+id/textView1"
    android:layout_width="170dp"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:text="Firstname:"
    android:textAppearance="?android:attr/textAppearanceMedium" /&gt;


&lt;EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:inputType="textPersonName" &gt;

    &lt;requestFocus /&gt;
&lt;/EditText&gt;


&lt;TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:text="Lastname:"
    android:textAppearance="?android:attr/textAppearanceMedium" /&gt;


&lt;EditText
    android:id="@+id/editText2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:inputType="textPersonName" /&gt;


&lt;TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:text="E-mail:"
    android:textAppearance="?android:attr/textAppearanceMedium" /&gt;


&lt;EditText
    android:id="@+id/editText3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:inputType="textEmailAddress" /&gt;



&lt;TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:text="Gender:"
    android:textAppearance="?android:attr/textAppearanceMedium" /&gt;





&lt;RadioGroup
    android:id="@+id/radioGroup1"
    android:layout_width="224dp"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:orientation="horizontal" &gt;


    &lt;RadioButton
        android:id="@+id/radio0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:checked="true"
        android:text="Male:" /&gt;


    &lt;RadioButton
        android:id="@+id/radio1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:text="Female:" /&gt;

&lt;/RadioGroup&gt;







&lt;Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:text="Register" /&gt;
</code></pre>

<p></p>
