How to add dividers between disabled items in ListView? - Lollipop

微笑、不失礼 提交于 2019-12-09 12:22:06

问题


To add the dividers between disabled items (not clickable) in ListView for Android previous to Lollipop I override adapter's method areAllItemsEnabled() to return true. But now in Lollipop this method doesn't fix the problem. The dividers are invisible in ExpandableListView too.

Is there a way to fix this problem without adding the divider in my item layout?


回答1:


We ended up adding two Views of 1dp to fake the divider and checking on version to set Visibility. The problem is worse. We also needed to keep track of if the next row is enabled or not, if it is the last row. A lot of cheese on an already deficient ListView (as compared to UITableView for example).

if(isItemAvailable(item) || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    rowView = inflater.inflate(R.layout.size_row, parent, false);
} else {
    rowView = inflater.inflate(R.layout.size_row_with_divider, parent, false);
}


来源:https://stackoverflow.com/questions/27330230/how-to-add-dividers-between-disabled-items-in-listview-lollipop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!