[英]how to make a listview of objects in android and access the object fields by clicking listitems?
[英]Android: remove divider of some listitems in listview
我用BaseAdapter
创建了一个listview。 我想要一些listitems有一个分隔符,但是从一些listitems,我想删除分隔符。 我知道你可以通过设置.setDivider(null)
和.setDividerHeight(0)
来删除整个列表的分隔符,但是也可以从列表中的单个列表项中删除分隔符吗?
提前致谢!
您可以为整个列表禁用分隔符,并为每个ListItem
设置自定义视图,例如设置具有或不具有底部边框的不同背景绘制。
是的,您可以使用适配器中的`getView`方法从特定列表项中删除分隔符(扩展baseadapter)
ofc你的适配器中有类似data
东西,这些数据是指显示在listview中的数据,所以在你的getview
方法中检查这样的特定项:
if(data[position].ID == YourElemetnsID)
inflate with the specific list item layout
else
inflate with the general list item layout
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.