Search code examples
androidonclickactionlisteneronlongclicklistener

Android touch listeners?


I need to nest s few touch listeners. For example I have a ViewGroup that will have the following listeners: onItemClick, onLongItemClick and onTouch.EV == move.

The items inside the view group will have an onClick as well.

In my tests both sets of listeners work independently, but not interdependently. Is there any way I can interlink the listener groups?

Thanks, ~Aedon


Solution

  • i´m not sure, but maybe you can dispatch the touch event from the root view to its child view (starting with the activity)

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (ChildView.dispatchTouchEvent(event))
            return true;
        else
            return false;
    }
    

    after the user clicked the button, dispatch the touch event back to the root view.