I have a button that types something in edit text and I am using on touch listener to do so when I press for audio to get played when left number gets typed.
zero.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){
sp.play(soundIdShot1, 1, 1, 0, 0, 1f);
rect = new Rect(zero.getLeft(), zero.getTop(), zero.getRight(), zero.getBottom());
}
if(motionEvent.getAction() == MotionEvent.ACTION_MOVE){
if(!rect.contains(zero.getLeft() + (int) motionEvent.getX(), zero.getTop() + (int) motionEvent.getY())){
}
} if(motionEvent.getAction() == MotionEvent.ACTION_UP){
number.append("0");
}
So, what I want to do is when I press, a sound is made and when I remove my finger the number gets typed in edit text field and when I move my finger outside the button's region with swipe nothing happens and nothing gets typed so as you get from the code I made it work with action down and action up but I can't figure it out with action move and how to make it work as I want