Giter VIP home page Giter VIP logo

pinnedheaderlistview's People

Contributors

duncandee avatar jimismith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pinnedheaderlistview's Issues

why i can't add header for list view

hi,
i can't add view for list view, like this :
mListView.addFooter(layout);
the error :
java.lang.ClassCastException: android.widget.HeaderViewListAdapter cannot be cast to za.co.immedia.pinnedheaderlistview.SectionedBaseAdapter

please check this and fix it

Positions for section and item are wrong when set PinnedHeaderListView.OnItemClickListener

I tried to track positions for section and item, so I added codes below into your sample project:

        listView.setOnItemClickListener(new PinnedHeaderListView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int section, int position, long id) {
                Toast.makeText(MainActivity.this, "onItemClick: Section: " + section + " Position: " + position, Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onSectionClick(AdapterView<?> adapterView, View view, int section, long id) {
                Toast.makeText(MainActivity.this, "onSectionClick: Section: " + section, Toast.LENGTH_SHORT).show();
            }
        });

But, all toasted messages imply the section and position are wrong. For example,

  • when the HEADER 1 is clicked, "onSectionClick: Section: 0" is toasted;
  • when the HEADER 2 is clicked, "onSectionClick: Section: 0 Position: 0" is toasted;
  • when the Header for section 0 is clicked, "onSectionClick: Section: 0 Position: 1" is toasted;
  • when the Section 0 Item 14 is clicked, "onSectionClick: Section: 1 Position: 0" is toasted.

So I reckoned codes

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) {
            SectionedBaseAdapter adapter;
            if (adapterView.getAdapter().getClass().equals(HeaderViewListAdapter.class)) {
                HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter();
                adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter();
            } else {
                adapter = (SectionedBaseAdapter) adapterView.getAdapter();
            }
            int section = adapter.getSectionForPosition(rawPosition);
            int position = adapter.getPositionInSectionForPosition(rawPosition);

            if (position == -1) {
                onSectionClick(adapterView, view, section, id);
            } else {
                onItemClick(adapterView, view, section, position, id);
            }
        }

may be not accurate, which is from OnItemClickListener implements AdapterView.OnItemClickListener.

So could you fix it?

tag return null from getView !!

Hi jimi,
when setTag in getView function and return it from activity return null ?! can check what happend .
sorry i don't have log just null pointer exception ..

Is it safe to replace android-support-v4.jar with latest's

From time to time, Google will release an updated version of android-support-v4.jar. I was wondering, is it safe for me, to just simply replace the old PinnedHeaderListView-master\library\libs\android-support-v4.jar with the latest?

Thanks.

How to get the local refresh

  • I am a Chinese. My English is not very good, forgive me!

First thanks for your library.I'm using it.

My Issues:
I want to use this library to realize partial refresh(A single item to refresh,including SectionHeader and ListView's Item).

I use listview's "getChildAt(int index)" return is a SectionHeaderView.(My English is not very good, forgive me!(^__^))

How make?

Making the library generic like ArrayAdapter<T>

Hi Jimi Smith,

First of all, I really would like to thank you for creating such a great library. Although I had looked into several tutorials to do my own implementation, none of them meet my requirement.

Till I found your libraries. It really saves me from few days of works. Once again, thank you so much! One thing I like about the library is that, it takes care of different convert views.

Making the library generic like ArrayAdapter would be great. But so far, I can live without it :)

How to request focus for section headers when there are items behind them?

My situation is like this: I placed a button inside one section header. It was clickable when there are no items behind that section header. But to my surprise, when I was scrolling down the ListView and there were section items behind the section header, the items got focus instead of the header. This is abnormal as one might expect. Is there any means to circumvent this behavior? Please be kind to reply me because there's a deadline of my project.

Changing text of Header when user clicks of an item.

I need to change the text of the pinned header when user clicks on an item. Suppose, user clicks on the first item, I need to show "1" in the pinned header, when user clicks on 2nd item on any group (means, items under that header), I need to show "2" in the pinned header.

My question is how can I get/access the header from an item's onClickListener? Is there any way like getHeaderViewByPosition(int section_position) ... or anything like this?

Wrong section & position in onSectionClick/onItemClick

When I add a header to the ListView by code e.g:
PinnedHeaderListView listView = (PinnedHeaderListView) view.findViewById(R.id.pinnedListView); LinearLayout header1 = (LinearLayout) inflater.inflate(R.layout.menu_left_header_profile, null); listView.addHeaderView(header1);

the position / section in onSectionClick/onItemClick is invalid....

In PinnedHeaderListView.OnItemClickListener you do not take into account the numbers of headers added to the ListView

rawPosition in public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) contains the number of rows and headers.

I fix it by add line:

rawPosition -= ((ListView) adapterView).getHeaderViewsCount();

in:

public static abstract class OnItemClickListener implements AdapterView.OnItemClickListener {
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) {
        SectionedBaseAdapter adapter;
        if (adapterView.getAdapter().getClass().equals(HeaderViewListAdapter.class)) {
            HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter();
            adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter();
        } else {
            adapter = (SectionedBaseAdapter) adapterView.getAdapter();
        }

        rawPosition -= ((ListView) adapterView).getHeaderViewsCount();

        int section = adapter.getSectionForPosition(rawPosition);
        int position = adapter.getPositionInSectionForPosition(rawPosition);

        if (position == -1) {
            onSectionClick(adapterView, view, section, id);
        } else {
            onItemClick(adapterView, view, section, position, id);
        }
    }

    public abstract void onItemClick(AdapterView<?> adapterView, View view, int section, int position, long id);

    public abstract void onSectionClick(AdapterView<?> adapterView, View view, int section, long id);

}

Different getCountForSection() for each sections?

If we have different item counts for each sections, then how to alter the adapter as shown in the sample?Right now, the different sections should have equal number of items to work, like shown in your sample.

Thanks!

How to intercept touch events on the pinned section view?

When a section view is pinned at the top of screen, it becomes the pinned section view, any touch events like click, swipe will be passed to the item views behind it. But when a section view is not pinned, any click events can be listened. So do you have any idea to intercept click events occurred on a pinned section view?

add pull to refresh?

Hello ,
First thanks for your library i loved it ๐Ÿ‘
second i want to implement pull to refresh class to your library but sections and positions not correct..
can you help me with this issue

thanks ..

How to request focus for section headers when there are items behind them?

My situation is like this: I placed a button inside one section header. It was clickable when there are no items behind that section header. But to my surprise, when I was scrolling down the ListView and there were section items behind the section header, the items got focus instead of the header. This is abnormal as one might expect. Is there any means to circumvent this behavior? Please be kind to reply me because there's a deadline on my project.

Error when addHeaderview

hi JimiSmith,
I'm using your PinnedHeaderListView class and it works well, but when I add a headerview it doesn't work what i want, the header view which I added is replaced by a blank section header view. below is my sectionadapter class code, and what should I do. thanks.

public View getItemView(int section, int position, View convertView, ViewGroup parent) {
    ItemViewHolder holder = null;
    if (convertView == null) {
        holder = new ItemViewHolder();
        convertView = (LinearLayout) this.mInflater.inflate(R.layout.view_add_friend_item, null);
        holder.headimg = (ImageView)convertView.findViewById(R.id.iv_addfriend_avater);
        holder.nickname = (TextView)convertView.findViewById(R.id.tv_addfriend_friend_name);
        holder.desc = (TextView)convertView.findViewById(R.id.tv_addfriend_friend_des);
        holder.addbtn = (Button)convertView.findViewById(R.id.bt_addfriend_add);

        convertView.setTag(holder);  
    } else {
        holder = (ItemViewHolder) convertView.getTag();
    }
    UserSection currentSection = sectionList.get(section);
    List<UserInfo> userList = currentSection.getUserList();
    UserInfo currentUser = userList.get(position);
    holder.nickname.setText(currentUser.getName());
    Utils.setPortrait(this.mContext, currentUser.getHeaderS(), holder.headimg);

    return convertView;
}

@Override
public View getSectionHeaderView(int section, View convertView, ViewGroup parent) {
    HeaderViewHolder holder = null;
    if (convertView == null) {
        holder = new HeaderViewHolder();
        LayoutInflater inflator = (LayoutInflater)parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = (LinearLayout) inflator.inflate(R.layout.item_section_adapter_header, null);
        holder.title = (TextView)convertView.findViewById(R.id.tv_section_title);
        convertView.setTag(holder);

    } else {
        holder = (HeaderViewHolder) convertView.getTag();
    }
    UserSection currentSection = sectionList.get(section);
    holder.title.setText(currentSection.getSectionTitle());
    return convertView;
}

Pinned Section Header flickers

When scrolling slowly downward (and the new section header moves upward), the newly pinned header flickers out / disappears for a split second showing the old pinned header that it replaced. It quickly flickers back in and is correctly presented. This isn't noticeable generally when scrolling fast.

Item can be selected if they are hidden behind a header

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

NullPointerException OnScroll

Hi,
I implemented this library in my project and i recieve a lot (!) of error reports all like this:

Stack trace: java.lang.NullPointerException
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:578)
at android.view.View.measure(View.java:16831)
at PinnedHeaderListView.ensurePinnedHeaderLayout(PinnedHeaderListView.java:138)
at PinnedHeaderListView.getSectionHeaderView(PinnedHeaderListView.java:121)
at PinnedHeaderListView.onScroll(PinnedHeaderListView.java:85)
at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1757)
at android.widget.ListView.layoutChildren(ListView.java:1774)
at android.widget.AbsListView.onLayout(AbsListView.java:2447)
at android.view.View.layout(View.java:15204)
at android.view.ViewGroup.layout(ViewGroup.java:4793)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
at android.view.View.layout(View.java:15204)
at android.view.ViewGroup.layout(ViewGroup.java:4793)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:15204)
at android.view.ViewGroup.layout(ViewGroup.java:4793)
at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:502)
at android.view.View.layout(View.java:15204)
at android.view.ViewGroup.layout(ViewGroup.java:4793)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:15204)
at android.view.ViewGroup.layout(ViewGroup.java:4793)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15204)
at android.view.ViewGroup.layout(ViewGroup.java:4793)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1666)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1442)
at android.view.View.layout(View.java:15204)
at android.view.ViewGroup.layout(ViewGroup.java:4793)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
at android.view.View.layout(View.java:15204)
at android.view.ViewGroup.layout(ViewGroup.java:4793)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:15204)
at android.view.ViewGroup.layout(ViewGroup.java:4793)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:15204)
at android.view.ViewGroup.layout(ViewGroup.java:4793)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2260)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2007)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6364)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:561)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
at dalvik.system.NativeStart.main(Native Method)

I can't figure it out. It never happened to me.
Is this a library bug? Is this a problem of mine?
Any hints where it can be?
Thanks!

Headers of varying sizes produce unexpected behavior

In this screenshot you can see a larger header and a smaller header, things look normal here.

screenshot_2013-12-08-19-09-19

In this screenshot you can see a weird empty space has occupied the top of the listview and the larger header has overlapped the smaller header.

screenshot_2013-12-08-19-09-26

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.