0
How do I put it for when a listview item has information it gets a background with a different color? In the example below it receives the data and returns them in listview:
public List<Cliente> todosOsClientes() {
List<Cliente> users = new ArrayList<>();
for (int i = 0; i < nome.length; i++) {
users.add(new Cliente(" " + nome[i], " Telefone: " + telefone[i], " Celular: " + celular[i],
" Renda: R$ " + renda[i], " Limite de Crédito: R$ " + limite[i], " Status: " + status[i],
" Bandeira: " + bandeira[i], "" + id[i]));
}
return users;
}
Inside the gone I tried:
if(status[i].contains("Devendo")){
lista.setBackgroundColor(0xFFDDEEFF);
}
But all of it is in blue, I wanted only those that contain the text "Owing"
Basedapter:
public class AdapterClientesPersonalizado extends BaseAdapter {
private final List<Cliente> cliente;
private final clientes act;
public AdapterCursosPersonalizado(List<Cliente> cliente, clientes act) {
this.cliente = clientes;
this.act = act;
}
@Override
public int getCount() {
return cliente.size();
}
@Override
public Object getItem(int position) {
return cliente.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = act.getActivity().getLayoutInflater().inflate(R.layout.lista_cliente_personalizada, parent, false);
Cliente cliente = cliente.get(position);
TextView nome = (TextView)
view.findViewById(R.id.lista_personalizada_nome);
TextView telefone = (TextView)
view.findViewById(R.id.lista_personalizada_telefone);
TextView celular = (TextView)
view.findViewById(R.id.lista_personalizada_celular);
TextView renda = (TextView)
view.findViewById(R.id.lista_personalizada_renda);
TextView limite = (TextView)
view.findViewById(R.id.lista_personalizada_limite);
TextView status = (TextView)
view.findViewById(R.id.lista_personalizada_status);
TextView bandeira = (TextView)
view.findViewById(R.id.lista_personalizada_bandeira);
TextView id = (TextView)
view.findViewById(R.id.lista_personalizada_id);
nome.setText(cliente.getNome());
telefone.setText(cliente.getTelefone());
celular.setText(cliente.getCelular());
renda.setText(cliente.getRenda());
limite.setText(cliente.getLimite());
status.setText(cliente.getStatus());
bandeira.setText(cliente.getBandeira());
id.setText(cliente.getId());
return view;
}
}
In case list would be your listview? What is the Adapter of the data? With a custom Adapter you can do this in the item. But it would encourage you to use a Recyclerview and do the Adapter.
– AndersonCanteiro
Yes, the list is listview, the Adapter is the Basedapter
– Woton Sampaio
has how you post the basedapter? so I can help better
– AndersonCanteiro
Blz, just a moment
– Woton Sampaio