PinnedHeaderListView icon indicating copy to clipboard operation
PinnedHeaderListView copied to clipboard

Item can be selected if they are hidden behind a header

Open bmarty opened this issue 12 years ago • 15 comments

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

bmarty avatar Mar 22 '13 12:03 bmarty

Hi

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

JimiSmith avatar Mar 25 '13 06:03 JimiSmith

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

bmarty avatar Mar 25 '13 08:03 bmarty

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.

JimiSmith avatar Mar 25 '13 08:03 JimiSmith

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

bmarty avatar Mar 25 '13 08:03 bmarty

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.

dannysunyu avatar Apr 03 '13 09:04 dannysunyu

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

JimiSmith avatar Apr 03 '13 09:04 JimiSmith

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

JimiSmith avatar Apr 04 '13 18:04 JimiSmith

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!

dannysunyu avatar Apr 07 '13 03:04 dannysunyu

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.

jacobtabak avatar Dec 09 '13 01:12 jacobtabak

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

varunbadgujar avatar Aug 07 '14 10:08 varunbadgujar

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

jacobtabak avatar Aug 07 '14 15:08 jacobtabak

@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 ?

varunbadgujar avatar Aug 08 '14 11:08 varunbadgujar

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

jacobtabak avatar Aug 09 '14 17:08 jacobtabak

@JimiSmith any update for resolve this issue ?

varunbadgujar avatar Aug 11 '14 12:08 varunbadgujar

@JimiSmith Hi, have you resolved this issue??

huluwa-dev avatar Aug 26 '14 03:08 huluwa-dev