【发布时间】:2012-11-28 02:39:06
【问题描述】:
我正在尝试将 CAB(上下文操作栏)添加到我的应用程序中的 ListView 中,除了一件事之外,一切都很顺利。当我最初添加 CAB 时,尽管选择了它,但当我长按它时背景颜色并没有改变。我对此的解决方案是覆盖 onItemCheckedStateChanged 并在那里设置背景颜色。我的问题是,当我尝试将背景颜色设置为之前的颜色时,我不能。 ListView 背景似乎已褪色,这意味着我无法选择与背景融为一体的颜色。你们是怎么做到的?这是我的代码:
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position,
long id, boolean checked) {
if (checked) {
//#6DCAEC is a type of Holo Blue that I want.
listView.getChildAt(position).setBackgroundColor(Color.parseColor("#6DCAEC"));
} else {
//#f1f1f1 was the closest I could get to the background put it still seems out of place
listView.getChildAt(position).setBackgroundColor(Color.parseColor("f1f1f1"));
}
}
【问题讨论】:
-
CAB退出后要清除突出显示的项目背景吗?
-
@Singularity 是的,这就是我想要做的。
标签: android select android-actionbar cab