I thought my code would work, but I guess not. I’m just trying to get it to read when the phone is touched. An animation will happen while its held. Then I would like it to determine when it is released so the animation will stop. My code looks like this with toasts as fillers until I get it working.
ImageView image = (ImageView)findViewById(R.id.pImage);
image.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN: {
Toast.makeText(PalsPage.this, "Is DOWN", Toast.LENGTH_SHORT).show();
break;
}
case MotionEvent.ACTION_UP: {
Toast.makeText(PalsPage.this, "Is UP", Toast.LENGTH_SHORT).show();
break;
}
return false;
}
});
Any help would be appreciated. Thanks
I think you are getting only the “Is DOWN” Toast.
The problem is in the return value.
You have to return
truefor the code to work.otherwise the ACTION_UP event will not come to this view’s listener.