EnhancedListView
EnhancedListView copied to clipboard
Can't implement onClick() in child views when onTouch() (swiping) is enabled
Clicks are not detected in child views of EhancedListView (at least I couldn't get it to work consistently). Here's what I put into the EhancedListView's onTouchEvent():
case MotionEvent.ACTION_UP: {
if (mVelocityTracker == null) {
break;
}
float deltaX = ev.getRawX() - mDownX;
// CODE ADDED HERE
// detects a click and passes the click
// onto the child view. without this, there
// is no click vs. swipe detection
if (deltaX == 0) {
mSwipeDownView.callOnClick();
// this was only a press, not a swipe
return false;
}
// CODE ADDED END
mVelocityTracker.addMovement(ev);
mVelocityTracker.computeCurrentVelocity(1000);
This works on my Droid Maxx, 4.2.2. Still have to test it on other devices. I'd like to know if you see any problems with it. Thanks! --Dave A
Edit: for the above, a AdapterView.OnItemClickListener() needs to be added to the child view that has it's callOnClick() method called.
Hei, have you also tried the solution from https://github.com/timroes/EnhancedListView/wiki#wiki-troubleshooting ?
No. The problem I'm having is that if I setOnClickListener() for a TextView in the EnhancedListView, the click works, but it won't swipe on that TextView.
David S Alderson
On Mon, Feb 10, 2014 at 2:27 PM, Tim Roes [email protected] wrote:
Hei, have you also tried the solution from https://github.com/timroes/EnhancedListView/wiki#wiki-troubleshooting ?
Reply to this email directly or view it on GitHubhttps://github.com/timroes/EnhancedListView/issues/34#issuecomment-34684435 .
"No" like, you haven't tried, or "no" like you tried it and it doesn't work? If you haven't tried it, please try the solution and give feedback if it worked.
Sorry, I worded that badly. I have tried the solution and it's not working for me.
I'm having the opposite problem. I'm getting clicks within the list item and am processing then properly. Instead, swiping doesn't work on the views that have onClick.
Thanks, Dave On Feb 11, 2014 12:29 AM, "Tim Roes" [email protected] wrote:
"No" like, you haven't tried, or "no" like you tried it and it doesn't work? If you haven't tried it, please try the solution and give feedback if it worked.
Reply to this email directly or view it on GitHubhttps://github.com/timroes/EnhancedListView/issues/34#issuecomment-34731805 .
Just fyi...
android:descendantFocusability="blockDescendants"
should have an "s" at the end of "block" and should be
android:descendantFocusability="blocksDescendants"
David S Alderson
On Tue, Feb 11, 2014 at 12:29 AM, Tim Roes [email protected] wrote:
"No" like, you haven't tried, or "no" like you tried it and it doesn't work? If you haven't tried it, please try the solution and give feedback if it worked.
Reply to this email directly or view it on GitHubhttps://github.com/timroes/EnhancedListView/issues/34#issuecomment-34731805 .
android:descendantFocusability="blocksDescendants" didn't work for me either - nexus 4, android 4.4
I also encounter the same problem, any solutions here?
sameproblem