Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item can be selected if they are hidden behind a header #6

Open
bmarty opened this issue Mar 22, 2013 · 15 comments
Open

Item can be selected if they are hidden behind a header #6

bmarty opened this issue Mar 22, 2013 · 15 comments

Comments

@bmarty
Copy link

bmarty commented Mar 22, 2013

Hello,

I'm using your amazing PinnedHeaderListView for my project, and I encountered this issue: when scrolling, item are displayed behind the pinned header, which is what I expects, but if I click on the header, then the item behind is selected. I wnat this to have no effect.

Do you have the same behavior on your project?

I've added this in my SectionedBaseAdapter class to avoid selection of header:
@OverRide
public boolean isEnabled(int position) {
return !isSectionHeader(position);
}

But even without this function the issue is observed.

Moreover, I observed a secondary issue (but less critical for my project): The first header is not clickable. That is onSectionClick function is never called for him. I've not investigated this issue.

After having looking for a solution without success, I ask for an idea here.

Any way thank you for sharing your component.

bma

@JimiSmith
Copy link
Owner

Hi

I've noticed this behaviour myself - I'm hoping to get some time later this week to fix it

@bmarty
Copy link
Author

bmarty commented Mar 25, 2013

Hello,

I've made a quite ugly fix for the issue. I've added setOnTouchListener(this); in the PinnedHedaerListView constructor and this method:

    /**
     * OnTouchListener interface
     */
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        // Ignore touch event on the current header, else the hidden item
        // can be selected.
        if (mCurrentHeader == null) {
            return false;
        }

        // Consume event if it is on the current header
        if (event.getY() < mCurrentHeader.getHeight()) {
            return true;
        }

        return false;
    }

Note that it can also fix the click issue, but is also disable the scroll on this region...

Maybe it can be improved to solve the issue "The first header is not clickable".

BR

@JimiSmith
Copy link
Owner

That's similar to what I was thinking of doing - except I was thinking of doing it in [performItemClick](http://developer.android.com/reference/android/widget/AdapterView.html#performItemClick(android.view.View, int, long)) or performClick.

That should solve the issue of scrolling not working in that region.

I haven't tested that out at all though, so it it may not work.

@bmarty
Copy link
Author

bmarty commented Mar 25, 2013

Your solution looks better :-). However, how will you get the coordinate of the touched area?

@dannysunyu
Copy link

My issue is similar to bmarty except I want the section header to be clickable instead of the items when they are behind that section header.

@JimiSmith
Copy link
Owner

Yes, this bug report is about making the section header clickable

JimiSmith pushed a commit that referenced this issue Apr 4, 2013
…on headers

The pinned section header will now receive the click event

This is partway to resolving #6
@JimiSmith
Copy link
Owner

I've pushed a commit to the dev branch which should prevent the list items from getting the click events. The section header should receive touch events as well, but I haven't tested this fully

@dannysunyu
Copy link

I owe you a big thank, Jimi. Recently I am working on an app that requires this pinned header feature and I found flaws with your library. But after reporting to you, you come to my rescue in time. I try out the demo now and it appears to resolve the issue. But I am going to make a further examination. Hope this time it works!

@jacobtabak
Copy link

Looks like there is still an issue with section headers receiving click events. They receive touch events unless they are the "current header" in which case they don't receive click events.

Also, if a non-header item is a layout and has clickable items in it, they can still receive touch events from behind the header view.

@varunbadgujar
Copy link

Issue is still active please provide a solution we all are waiting for this.

@jacobtabak
Copy link

@varunbadgujar can you try adding an onclicklistener to the header view that doesn't do anything?

@varunbadgujar
Copy link

@jacobtabak i did try this but its not working its taking touch of behind the header view.
@jacobtabak have you resolved this issue at your end ?

@jacobtabak
Copy link

@varunbadgujar no, I just saw your comment and thought it may be worth a shot. sorry to get your hopes up.

@varunbadgujar
Copy link

@JimiSmith any update for resolve this issue ?

@huluwa-dev
Copy link

@JimiSmith Hi, have you resolved this issue??

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

No branches or pull requests

6 participants