如何在ListView中禁用的项目之间添加分隔? - 棒糖 [英] How to add dividers between disabled items in ListView? - Lollipop

查看:179
本文介绍了如何在ListView中禁用的项目之间添加分隔? - 棒糖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在的ListView 为Android previous到棒棒堂我重写适配器的方法 areAllItemsEnabled( )返回true。但是,现在在棒棒堂这种方法并不能解决问题。该分频器是不可见 ExpandableListView 了。

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?

推荐答案

最后我们增加了两个意见1DP伪造分频器和检查的版本设置可见。这个问题更为严重。我们还需要下一行是否被启用与否,如果它是最后一行,以保持跟踪。对已经不足的ListView(与UITableView的为例)很多奶酪。

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);
}

这篇关于如何在ListView中禁用的项目之间添加分隔? - 棒糖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆