Well, I finally solved it, hope this helps someone:
What I did was created ArrayList<Integer>, which saves all the positions of the selected elements and switches the background colors to clicks.
In my adapter, I define:
public ArrayList<Integer> selectedIds = new ArrayList<Integer>();
Following method:
public void toggleSelected(Integer position)
{
if(selectedIds.contains(position))
{
selectedIds.remove(position);
}
else
{
selectedIds.add(position);
}
}
which adds / removes elements from an ArrayList
In my getView method:
if (selectedIds.contains(position)) {
convertView.setSelected(true);
convertView.setPressed(true);
convertView.setBackgroundColor(Color.parseColor("#FF9912"));
}
else
{
convertView.setSelected(false);
convertView.setPressed(false);
convertView.setBackgroundColor(Color.parseColor("#000000"));
}
This checks if the position is stored in the ArrayList. if so, color it as selected. if not, vice versa.
, OnItemClick, :
((YourAdapter)list.getAdapter()).toggleSelected(new Integer(position));
YourAdapter ListView
, , :)