I have come across a very strange behavior of SortedList
. The method indexOf
returns INVALID_POSITION
even though in the debugger everything seems okay.
Method getWorkingDayItems
of adapter workingDayAdapter
returns SortedList
.
As you can see, the 3rd element of the list is WorkingDay@4678
which is the same object as object workingDay
. Yet the method indexOf
returns -1.
Could you explain to me, why is this happening? Is there a known or not yet discovered but in the SortedList
? Or is there another cause?
Thank you.
EDIT:
After removing overriding of equals
method the problem persist.
In normal lists in java the indexOf() method compares with the equals() method (I haven't found it for SortedList). Could it be the problem that you haven't overriden the equals() method in your WorkingDay class? I think if you pass a new instance of WorkingDay@4678 into your indexOf() method it would classify it with -1.