I have a spinner that pulls the values from the bank but 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 only added at the end of the list.
I have also tried this way, but it does not generate the value because it is replaced:
ArrayList<ArrayCliente> clientes = ArrayList<>();
clientes.add(new ArrayCliente(0, "Selecione..."));
clientes = ctClientes.getClientes();