Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

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

Open
dsa027 opened this issue Feb 9, 2014 · 8 comments

Comments

@dsa027
Copy link

dsa027 commented Feb 9, 2014

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
Copy link
Owner

timroes commented Feb 10, 2014

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

@dsa027
Copy link
Author

dsa027 commented Feb 11, 2014

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//issues/34#issuecomment-34684435
.

@timroes
Copy link
Owner

timroes commented Feb 11, 2014

"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
Copy link
Author

dsa027 commented Feb 11, 2014

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//issues/34#issuecomment-34731805
.

@dsa027
Copy link
Author

dsa027 commented Feb 12, 2014

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//issues/34#issuecomment-34731805
.

@flash1293
Copy link

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

@lvsMark
Copy link

lvsMark commented Jul 25, 2015

I also encounter the same problem, any solutions here?

@SweetSourPeter
Copy link

sameproblem

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants