timroes / EnhancedListView

[DEPRECATED] An Android ListView with enhanced functionality (e.g. Swipe To Dismiss or Undo)
Other
463 stars 147 forks source link

Can't implement onClick() in child views when onTouch() (swiping) is enabled #34

Open dsa027 opened 10 years ago

dsa027 commented 10 years ago

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.

timroes commented 10 years ago

Hei, have you also tried the solution from https://github.com/timroes/EnhancedListView/wiki#wiki-troubleshooting ?

dsa027 commented 10 years ago

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 notifications@github.com 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 .

timroes commented 10 years ago

"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.

dsa027 commented 10 years ago

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" notifications@github.com 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 .

dsa027 commented 10 years ago

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 notifications@github.com 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 .

flash1293 commented 10 years ago

android:descendantFocusability="blocksDescendants" didn't work for me either - nexus 4, android 4.4

lvsMark commented 9 years ago

I also encounter the same problem, any solutions here?

SweetSourPeter commented 5 years ago

sameproblem