Daniel,
To implement this color change in the ListView, make a customAdapter that extends the ArrayAdapter, then inside it you implement this color change.
public class ArrayTeste extends ArrayAdapter {
List<Objeto> lista;
Context contexto;
public ArrayTeste(Context context, int resource, List<Objeto> lista) {
super(context, resource, lista);
this.lista = lista;
this.contexto = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Objeto objeto = lista.get(position);
if(objeto.isStatus()){
int cor = Color.parseColor("blue");
convertView.setBackgroundColor(cor);
}
return super.getView(position, convertView, parent);
}
public class Objeto{
private String Nome;
public String getNome() {
return Nome;
}
public void setNome(String nome) {
Nome = nome;
}
public boolean isStatus() {
return Status;
}
public void setStatus(boolean status) {
Status = status;
}
private boolean Status;
}
}
In the end I put a sample class just for you to understand.
Using this adapter, in your Activity call
meuAdapter.clear();
meuAdapter.addAll(listaObjetosAtualizados);
The notifyDataSetChanged()
command will only update an item that has been added or removed, it will not update a View that is already running.