我有ListView
,其方法为setOnItemLongClickListener
。每当我选择列表项时,ListView
中的某些列表项会自动被选中。这是我的代码
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
String present =listView.getItemAtPosition(position).toString();
presentStudent.add(present);
parent.getChildAt(position).setBackgroundColor(getResources().getColor(R.color.colorPrimary));
return true;
}
});
}