Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show / Hide Listview SectionIndex on demand

i implemented a listview which implements SectionIndexer ... everything fine so far.

Normally the items are sorted by Name, but i also offer the option to sort the list in a different way - by distance (from the user to the objects).

So, when the list is sorted the 2nd way, i want to hide the previously generated SectionIndex.

I'm just not able to do so.

I tried, re-writting most of the methods, I tried it with a separation in the Constructor (clear why it doesnt work, it doesnt get called a second time) I even tried it with implementing a second listadapter, and just using a different one? Even in this case the SEctionIndex is shown! I really don't understand this one.

So would be really great, if anyone knows whats going on :)

thanks a lot, mike

like image 882
cV2 Avatar asked Jul 24 '11 15:07

cV2


1 Answers

Your observations are correct. Let me tell you first why the constructor never gets called the second time. SectionIndexer are a special kind. They create the index only once for a particular set of data and re-use them on that adapter. The bigger issue which I had come across was when the underlying data changed for the adapter, the sectionIndexer still remained the same.

Check my Question and the answer there.

Coming back to your query here.

If you change the orientation after selecting the second option, you would observe that the constructor will get called and you will be able to re-populate the sectionIndex again. So basically you need to call onSizeChanged again and get the sectionIndex repopulated.

like image 166
PravinCG Avatar answered Oct 13 '22 00:10

PravinCG