I'm trying to get my schedule list to have each row with different colors for each category that was set, this list is populated by data retrieved from the firebase going to the template class, I wanted it when this DialogFragment was called to list the schedule it would differentiate each category by color (blue spiritual, yellow gymkhana, green leisure), it follows the code of my adapter where I try to change the color of each one of the lines:
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View view = null;
//Validando e criando a lista
if (arrayList != null){
LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
//Montando a view a partir do XML
view = inflater.inflate(R.layout.lista_cronograma, parent, false);
//Recuperando os elementos para exibição
TextView inicio = view.findViewById(R.id.tv_hora_inicio);
TextView fim = view.findViewById(R.id.tv_hora_fim);
TextView atividade = view.findViewById(R.id.tv_atividade);
Cronograma crono = arrayList.get(position);
inicio.setText(crono.getHoraInicio());
fim.setText(crono.getHoraFim());
atividade.setText(crono.getAtividade());
switch (crono.getCategoria()){
case "Espiritual":
inicio.setBackgroundColor(0xCFD8DC);
fim.setBackgroundColor(0xCFD8DC);
atividade.setBackgroundColor(0xCFD8DC);
view.setBackgroundColor(0xCFD8DC);
break;
case "Gincana":
inicio.setBackgroundColor(0xFFF9C4);
fim.setBackgroundColor(0xFFF9C4);
atividade.setBackgroundColor(0xFFF9C4);
view.setBackgroundColor(0xFFF9C4);
break;
case "Lazer":
inicio.setBackgroundColor(0xDCEDC8);
fim.setBackgroundColor(0xDCEDC8);
atividade.setBackgroundColor(0xDCEDC8);
view.setBackgroundColor(0xDCEDC8);
break;
}
}
return view;
}