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個項目延遲另一個隨機項目變成白色,就像它進入視圖一樣?有人可以幫幫我嗎??ListView項目更改顏色問題。多個項目向下改變視圖