0
基本上,我有一个错误,其中一些列表视图的子项将显示为选中状态,而实际上它们不是。例如,如果我输入ActionMode
并仅选择第一个孩子,则会显示其他几个孩子,尽管我选择了他们,但实际上并未选择。这是为什么发生?ListView - CHOICE_MODE_MULTIPLE_MODAL - 正在选择随机项目
public void onItemCheckedStateChanged(ActionMode mode, int position,
long id, boolean checked) {
final int checkedCount = lv.getCheckedItemCount();
mSelectedConvCount.setText(Integer.toString(checkedCount));
if (checked) {
lv.getChildAt(position).setBackgroundColor(
Color.BLUE);
} else {
lv.getChildAt(position).setBackgroundColor(
Color.TRANSPARENT);
}
}
}
也许你不能只使用getChildAt方法和position作为参数来获取子视图。孩子的位置是不同的。 – 2011-12-31 11:24:57
@ user674199在我看来,我已经这样做了。 – adneal 2012-01-05 11:50:33