1
The thing is, I created a Adapter amending a RecyclerView in an Activity I call through this function (within Activity):
 private void gerarDatasView(CalendarJur calendario){
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, false);
        listDatas.setLayoutManager(linearLayoutManager);
        ListDatasAdapter adapter = new ListDatasAdapter();
        adapter.setDateJur(calendario.getDatas());
        listDatas.setAdapter(adapter);
    }
The listDatas is the RecyclerView.
And it works perfectly according to the image:
Each item in this list was created through onBindViewHolder in my Adapter like this:
public void onBindViewHolder(@NonNull final ViewListDatas holder, int position) {
        DateJur data = datas.get(position);
        holder.diaMes.setText(data.getDiaMes());
        holder.diaSemana.setText(data.getDiaSemana());
        if(holder.getAdapterPosition() == posNow){
            holder.btn.setImageResource(R.drawable.background_date_layout_selected);
            posNow = holder.getAdapterPosition();
        }
        holder.btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                holder.btn.setImageResource(R.drawable.background_date_layout_selected);
                // muda a cor de fundo conforme o click
            }
        });
    }
When I click on another date the background color changes the way I want, but the old date would have to stay with the default background (white), but both are with the selected background (blue) see:
My question:
How do I let the adapter know that it has to change the other item to the default color after a click?
There’s a way to control it inside the Adapter or I’d have to do it another way?
As I did not want to leave the question too extensive, I put the codes I think are necessary, but if you need other information just ask.


Great idea! I got another way... I’ll post too later. I will not mark as sure yet because I want to test and see if other answers appear. But.. thank you very much!
– Andrei Coelho