How to detect when a user taps on a view in Android
<p>I want to detect when a user taps anywhere in a view in my Android application.</p>

<p>My code looks like this:</p>

<pre><code>linearLayout = (LinearLayout) findViewById(R.id.linearLayout); // main layout
// ...
linearLayout.setOnTouchListener(this);
// ...
public boolean onTouch(View v, MotionEvent event) {
    Toast.makeText(this, "Touch!", 1000);
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        Toast.makeText(this, "Down!", 1000);
        return true;
    }
    return false;
}   
</code></pre>

<p>...but when I click on the view, I don't get Toast!</p>

<p>Do touch events work in the emulator -- or have I got something wrong in my code?</p>
