P
P
Petr Petrovich2018-06-03 14:40:54
Java
Petr Petrovich, 2018-06-03 14:40:54

Android onTouchEvent?

I have a listView, in the onItemLongClickListener method, I want a dialog-like view to be displayed on the screen on top of the list, with some details. When the finger is removed from the screen, we want this view to disappear. To hide the view, you need to handle the onTouchEvent event:

view.setOnTouchListener((v, event) -> {
    if (event.getAction() == MotionEvent.ACTION_UP) {
        view.setVisibility(View.GONE);
        return true;
    }
    return false;
});

Problem: how to switch event handling from listView to this View when it is displayed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question