Android: remove separator of some lists in listview

I created a list with a BaseAdapter . I want some of the lists to have a separator, but from some lists I want to remove the separator. I know that you can remove the separator of the entire list by setting .setDivider(null) and .setDividerHeight(0) , but is it also possible to remove the separator from the same list in the list?

Thanks in advance!

+6
source share
2 answers

You can disable the separator for the entire list and set your own view for each ListItem , for example. customization of various background images with or without a lower border.

+5
source

Yes, you can remove the separator from certain list items using the getView method in your adapter (which extends the base adapter)

ofc you have something like data in your adapter that references the data displayed in the list, so in your getview method getview check for specific elements as follows:

 if(data[position].ID == YourElemetnsID) inflate with the specific list item layout else inflate with the general list item layout 
+2
source

All Articles