Android Touch listeners?

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

Elements within the view group will also have onClick.

In my tests, both sets of listeners work independently, but not interdependently. Is there a way to connect groups of listeners?

Thanks ~ Aedona

+3
source share
2 answers

I'm not sure, but maybe you can send a touch event from the root view to its child view (starting from the action).

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

after the user clicked the button, send the touch event back to root mode.

+3
source

. , . , ViewGroup, , . false , , true , .

, ViewGroup. , ViewGroup , , .

+2

Source: https://habr.com/ru/post/1795304/


All Articles