It turns out that I'm doing an app that contains a list that is launched from CustomDialog
. When selecting one or more of its items I save the ID's in an array, thus leaving [1, 3, 5, 6]
. With a "Cancel" button the ArrayList
is cleared and the dialog is closed.
deleteIds.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
myArrayList.clear();
dialogView.dismiss();
}
});
The problem comes with the other button that is "Save" whose action is only to close the dialog so the list stays loaded with the elements that I selected. The point is that when you reopen the dialog and choose an item that you had already loaded before, the list stays like this: [1, 1, 3, 5, 6]
. Is there any way to imply that it has already been marked? How do I verify if that item I selected again is already loaded in the list?
I was thinking of something similar to giving it a different color within setOnItemClickListener
.
view.setBackgroundColor(Color.parseColor("#ADD8E6"));
I have been told that I can leave the ones I already have selected in the list painted in a different color, but I do not know how to do it. I hope you can help me and thanks in advance!