I am continuing work on my Sticky ListView, in which a specified view in a ListView will stick to the top and/or bottom as it passes by. I've accomplished this by setting up a View that is identical to the list item, and showing or hiding it as the list item passes on and off the screen.
My problem is, that when these 'sticky' items are present, I want them to react to touch as if they are part of the listview itself. For example, a fling down on the top sticky should send the listview scrolling down.
My question is if it's possible to assign an touch listener to this view, and then pass these events directly to the list.
I was hoping it would be as easy as:
ListView list;
....
stickyview.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent motionEvent) {
list.onTouchEvent(motionEvent);
return false;
}
});
I got it with some slight tweaking:
stickyView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return list.onTouchEvent(event);
}
});
I had to use dispatchTouchEvent(MotionEvent event)
to achieve this in my situation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With