lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
if (selectedCourses.contains(courseNames.get(position))){
selectedCourses.remove(selectedCourses.lastIndexOf(courseNames.get(position)));
Toast.makeText(getApplicationContext(),
courseNames.get(position) + " removed", Toast.LENGTH_LONG)
.show();
row = view;
row.setBackgroundResource(R.drawable.charback);
System.out.println(selectedCourses);
}
else{
selectedCourses.add(courseNames.get(position));
Toast.makeText(getApplicationContext(),
courseNames.get(position) +" added", Toast.LENGTH_LONG)
.show();
row = view;
row.setBackgroundResource(R.drawable.white);
myarrayAdapter.notifyDataSetChanged();
System.out.println(selectedCourses);
}
选定的项目变白,但迟到了大约 12 个项目,另一个随机项目在进入视野时变白?有人可以帮帮我吗??