1
I have a spinner that pulls the bank values, but I would like to leave it with nothing selected or default value:
public void spinnerClientes() {
ControllerClientes ctClientes = new ControllerClientes(this);
ArrayList<ArrayCliente> clientes = ctClientes.getClientes();
clientes.add(new ArrayCliente(0, "Selecione..."));
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, clientes);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnClientes.setAdapter(adapter);
}
The problem is that trying to create the default value clientes.add(new ArrayCliente(0, "Selecione..."));
this value is added only at the end of the list.
I’ve tried that way too, but it doesn’t generate value because it’s replaced:
ArrayList<ArrayCliente> clientes = ArrayList<>();
clientes.add(new ArrayCliente(0, "Selecione..."));
clientes = ctClientes.getClientes();
It worked perfectly, but I found the @Isac way more practical ! Thank you !
– rbz
Possibly more practical but with less performance :).
– ramaral
So I’m going to use this way, one less item to lower performance !
– rbz