У меня есть представление списка, которое показывает ArrayList объекта (класс "Doenca"), и это предупреждение появляется в моем инфляторе, я использую адаптер ListView в классе. Смотрите:
public class DoencaAdapter extends ArrayAdapter<Doenca> {
private final Context context;
private final ArrayList<Doenca> doencaArrayList;
public DoencaAdapter(Context context, ArrayList<Doenca> doencaArrayList) {
super(context, R.layout.linhas_dados_patologia_grupo, doencaArrayList);
this.context = context;
this.doencaArrayList = doencaArrayList;
}
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View root = inflater.inflate(R.layout.linhas_dados_patologia_grupo, parent, false);
// Indicando quem é quem no layout XML
TextView nomeDoenca = root.findViewById(R.id.doencaNome);
TextView causaDoenca = root.findViewById(R.id.doencaCausa);
TextView efeitoDoenca = root.findViewById(R.id.doencaEfeito);
TextView cuidadoDoenca = root.findViewById(R.id.doencaCuidados);
TextView prevencaoDoenca = root.findViewById(R.id.doencaPrevencao);
TextView categoriaDoenca = root.findViewById(R.id.doencaCategoria);
TextView criadorDoenca = root.findViewById(R.id.doencaCriador);
ImageView doencaFoto = root.findViewById(R.id.doencaFoto);
// Atribuindo valores a cada doença adicionada pelo usuário
nomeDoenca.setText(doencaArrayList.get(position).getNome());
causaDoenca.setText(doencaArrayList.get(position).getCausa());
efeitoDoenca.setText(doencaArrayList.get(position).getEfeito());
cuidadoDoenca.setText(doencaArrayList.get(position).getCuidados());
prevencaoDoenca.setText(doencaArrayList.get(position).getPrevencao());
categoriaDoenca.setText(doencaArrayList.get(position).getCategoria());
criadorDoenca.setText(FirebaseAuth.getInstance().getCurrentUser().getDisplayName());
switch (doencaArrayList.get(position).getCategoria().toString()){
case "Inflamação":
doencaFoto.setImageResource(R.mipmap.ic_doenca1);
// listView.setDivider(new ColorDrawable(context.getResources().getColor(R.color.preto1)));
break;
case "Infecção":
doencaFoto.setImageResource(R.mipmap.ic_doenca2);
// listView.setDivider(new ColorDrawable(context.getResources().getColor(R.color.amarelo2)));
break;
case "Zoonose":
doencaFoto.setImageResource(R.mipmap.ic_doenca3);
// listView.setDivider(new ColorDrawable(context.getResources().getColor(R.color.vermelho3)));
break;
case "Viral":
doencaFoto.setImageResource(R.mipmap.ic_doenca4);
// listView.setDivider(new ColorDrawable(context.getResources().getColor(R.color.azul4)));
break;
case "Outros":
doencaFoto.setImageResource(R.mipmap.ic_doenca5);
break;
default:
doencaFoto.setImageResource(R.mipmap.ic_doenca5);
// listView.setDivider(new ColorDrawable(context.getResources().getColor(R.color.laranja5)));
break;
}
return root;
}
}
Я не вижу ничего, что может вызвать это предупреждение. Но элементы моего списка отображаются нормально, только один элемент не отображается, но это должна быть база данных pu sh data.