我想设置列表视图所选项目的颜色。我已经设置了列表视图项目和颜色。
{
setListAdapter(new ArrayAdapter<String>(getActivity(),
R.layout.simple_list_item_checkable_1, android.R.id.text1,Data.PERSON));
ListView listView = getListView();
listView.setTextFilterEnabled(true);
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
View listItem = parent.getChildAt(i);
if (listItem != null)
parent.setBackgroundColor(0x00000000);
view.setBackgroundColor(Color.RED);
}
});
}