EnhancedListView icon indicating copy to clipboard operation
EnhancedListView copied to clipboard

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

Open dsa027 opened this issue 10 years ago • 8 comments

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.

dsa027 avatar Feb 09 '14 17:02 dsa027

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

timroes avatar Feb 10 '14 21:02 timroes

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 .

dsa027 avatar Feb 11 '14 00:02 dsa027

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

timroes avatar Feb 11 '14 07:02 timroes

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 .

dsa027 avatar Feb 11 '14 13:02 dsa027

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 .

dsa027 avatar Feb 12 '14 17:02 dsa027

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

flash1293 avatar Feb 26 '14 19:02 flash1293

I also encounter the same problem, any solutions here?

lvsMark avatar Jul 25 '15 02:07 lvsMark

sameproblem

SweetSourPeter avatar Apr 26 '19 20:04 SweetSourPeter