Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 801
Mario Kutlev Avatar asked Dec 06 '14 09:12

Mario Kutlev


1 Answers

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);
}
like image 59
840Ci Avatar answered Nov 08 '22 01:11

840Ci