0
I’m trying to get my schedule list to have each line with different colors for each category that was defined, this list is filled by data recovered from firebase that goes to the model class, wanted that when this Dialogfragment was called to list the schedule he differentiated each category by color (spiritual blue, yellow gymkhana, green leisure), follows the code of my Adapter where I try to change the color of each 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;
}
What’s wrong with the code?
– ramaral