0
votes

Ok... in my app i update the layout on MotionEvent.ACTION_DOWN and then i check the motion event coordinates to locate my buttons. I can show a toast when finger is released on different buttons. The problem is i need a long touch on my buttons to call another action without conflicting with the MotionEvent.ACTION_UP. Implemented a long click handler but since i don't 'click' its not working. Hope you guys understand my problem.

Whats the best way to get my app working as intended?

My class implements OnTouchListener, OnGestureListener

    @Override
public boolean onTouch(View v, MotionEvent event) {

    switch(event.getAction()){

    case MotionEvent.ACTION_DOWN:

        // UPDATE LAYOUT
            break;

        case MotionEvent.ACTION_UP:

        // GET BUTTON X Y           
            if (x and y match the button location){

                // DO ACTION

            }else{   

                // DO NOTHING

            }           
            // CHANGE LAYOUT TO INITIAL STATE   
            break;

        case MotionEvent.ACTION_MOVE:
            break;

    }

        return false;


     mybutton.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
                // DO STUFF
            return true;
        }
    });

}
1

1 Answers

0
votes

just try to return false in your onTouch(...) method and use onLongClickListener(...) as usual