简体   繁体   中英

Android: remove divider of some listitems in listview

I've created a listview with a BaseAdapter . I want some of the listitems to have a divider, but from some of the listitems, I want to remove the divider. I know you can remove the divider of the whole list by setting .setDivider(null) and .setDividerHeight(0) , but is it also possible to remove the divider from a single listitem inside a list?

Thanks in advance!

您可以为整个列表禁用分隔符,并为每个ListItem设置自定义视图,例如设置具有或不具有底部边框的不同背景绘制。

Yes you can remove divider from specific list items using the `getView` method in your adapter (which extends the baseadapter)

ofc you have something like data in your adapter which refers to the data been displayed into the listview, so in your getview method check for the specific items like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM