How to set up an onTouchListener that changes an ImageView image resource?
<p>I want to setup up an onTouchListener that changes an ImageViews image resource on ACTION_UP and ACTION_DOWN. Here is my code:</p>

<pre><code>    // Setup a basic upDownListener that registers UP and DOWN actions and changes the
    // view image resource accordingly
    View.OnTouchListener upDownListener = new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if(event.getAction() == MotionEvent.ACTION_DOWN) {
                // Button was pressed, change button background
                v.setImageResource(R.drawable.button_white_pressure);
                return true;
            } else if(event.getAction() == MotionEvent.ACTION_UP) {
                // Button was released, reset button background
                v.setImageResource(R.drawable.button_white);
                return true;
            }

            return false;
        }

    };
</code></pre>

<p>This code does not compile because View does not have the method setImageResource, only ImageView. But how do I tell the listener that an ImageView is being used?</p>
