I have seen on Google how to perform actions on MotionEvents of ImageView, what i want to do is change the image when user press the ImageView and reset to previous image when user release the ImageView, i am performing some reset code in my activity i just want an effect when user press the imageview.
Here is what i have done,
iv_reset.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
// TODO Auto-generated method stub
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
iv_reset.setImageResource(R.drawable.ic_action_reset_pressed);
iv_reset.invalidate();
break;
case MotionEvent.ACTION_UP:
iv_reset.setImageResource(R.drawable.ic_action_reset);
iv_reset.invalidate();
resetAll();
break;
default:
break;
}
The problem is when i touch the ImageView (iv_reset) it changes the image, but when i release the touch it remains changed and not resetting to previous image which should be done in MotionEvent.ACTION_UP: case i think.
Any help please.