Home » Android » android – "Separators" in ListView

android – "Separators" in ListView

Posted by: admin June 15, 2020 Leave a comment

Questions:

I have an ArrayAdapter which is hooked up to my ListView. I really like the “separators” feature in the Evernote Android application, where they separate items using a datestamp:

screenshot 1 screenshot 2 screenshot 3 enter image description here

I assume what they’re doing is having a view immediately above the list which is set to the value of the current separator, as you can see in the screenshots. (As you scroll past a separator, the text at the top is set to the value of the current separator, ie “January 2011”) How would I actually insert the separators into my ListView?

How to&Answers:

A separator is simply a disabled list item, just have your Adapter return the separator where it should be. Seems like SectionIndexer could help.

Answer:

And here is one which does exactly this : https://github.com/Polidea/android-section-list with transparent section header sticky at the top of the list (similar to iOS section list which comes out of the box there).

Answer:

We’re on our own on this one.

I made my own ListView with headers for one of my apps: Dhammapada (look for HeadingAdapter and associated classes)

Answer:

set two layouts on a single screen one above other…
then add scroll to layout which is below…
then add list view in d second half layout … fix it up and deploy ur sh$T and its done !!
Note : dont add scroll in main layout .. just on layout which is underneath :p

eg:-

<LL1 
bla bla
>

<LL2 bla bla>
</LL2>

<LL3 scroll bla bla>
<ListView bla bla>
</ListView> 

</LL3>

</LL1>