我想更改列表视图上单行的颜色。使用上下文菜单动态更改ListView行的背景颜色
我做了一个自定义适配器,我想该行的上下文菜单上的变化去色:
@Override
public boolean onContextItemSelected(MenuItem item) {
switch(item.getItemId()) {
case NOTE_BACKGROUND:
AdapterContextMenuInfo infos = (AdapterContextMenuInfo) item.getMenuInfo();
getListView().getAdapter().getView(infos.position, null,null).setBackgroundColor(Color.GREEN);
notes.notifyDataSetChanged();
return true;
}
return super.onContextItemSelected(item);
}
但它不工作...我不知道为什么。任何想法?非常感谢。