applidium / HeaderListView

Android ListView with sticky headers
http://applidium.com/en/news/headerlistview_for_android/
Other
313 stars 96 forks source link

Switching Header Label values #24

Open gasparuff opened 10 years ago

gasparuff commented 10 years ago

I'm showing a ListView with 3 sort buttons above it (Name, Country, Age). When sorting changes, I'm updating the HeaderListview like this: ((PeopleSectionedAdapter) listView.getAdapter()).setLinkedPeopleMap(indicesBR.get("name")); ((PeopleSectionedAdapter) listView.getAdapter()).notifyDataSetChanged(); or ((PeopleSectionedAdapter) listView.getAdapter()).setLinkedPeopleMap(indicesBR.get("country")); ((PeopleSectionedAdapter) listView.getAdapter()).notifyDataSetChanged(); or ((PeopleSectionedAdapter) listView.getAdapter()).setLinkedPeopleMap(indicesBR.get("age")); ((PeopleSectionedAdapter) listView.getAdapter()).notifyDataSetChanged();

Actually it works, but when I havent scrolled below the 2nd Header, the currently active header doesn't get changed at all. E.g. I have selected "Name" and I scrolled down just a very small amount - then the currently active header still says "A", while the next visible header displays the correct title. I'd have to scroll down until the next header gets active and then scroll back to update the previously active one. This problem doesn't occur if I don't do any scrolling at all. How can I fix this?

Wirwing commented 9 years ago

Any update on this? I need to change header values too!

JaydipMeghapara commented 8 years ago

It's working for me. Simply remove the all view of header when set adapter to list view. Change the setAdapter() of HeaderListView to

public void setAdapter(SectionAdapter adapter) { mAdapter = adapter; if(mHeader != null) mHeader.removeAllViews(); mListView.setAdapter(adapter); }