Disable ListView Listener Listener

I have a ListView with different types of strings. A string may contain text, image, video, or something else. If I click on the ImageView (inside the line), I will move on to another action to show the image in full screen. If I click on Video (inside the line), I will move on to another action to play its video.

I implemented listening to napkins from right to left in my ListView. If I start scrolling a ListView from white space into a ListView, the swipe works (first and second lines at the bottom of the image). However, if I started scrolling a ListView from a ListView row element, then the swipe does not work (the third and fourth rows at the bottom of the image). If I delete click events from ImageView and Video, then the swipe works even if I started scrolling from a ListView line item, i.e. In this case, the swipe will work throughout the ListView, regardless of which line I make the swipe.

enter image description here

How can I get rid of this problem? I think this can be achieved if I turn off all click events for all elements inside the ListView. How to do it? Is there another way?

I want to both scroll in the ListView and click on the ListView element.

+1
1

Trick way, listview onTouchListener, . viewview onTouch.

ImageView image; // your image view, and asuume the it is initialized.

row.setOnTouchListener(new View.OnTouchListener() {

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

    switch (event.getAction()) {

    case MotionEvent.ACTION_DOWN:                     
        image.onTouchEvent(event);
        break;                     
    }

    return false;
}

});

. , onTouchListener. , . "true" , .

0

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


All Articles