I have ListView
with several records and when I click on an item it opens in a new activity
taking the value of _id
of that item.
I get this _id
, I search SQLite, and fill in the fields as follows:
public void carregaValores(int id) {
DBController ctRegistro = new DBController(this);
ArrayList<CRegistros> registro = new ArrayList<>(ctRegistro.getRegistro(id));
this.vTipo = registro.get(0).getTipo();
this.data.setText(registro.get(0).getData());
this.horario.setText(registro.get(0).getHorario());
this.historico.setText(registro.get(0).getHistorico());
this.vClienteString = registro.get(0).getCliente();
}
The question now is how to set the spinners, since I do not have the position value, only the _id
registry to be able to compare.
I tried the following ways (as found by OS and SOpt):
1.
String compareValue = this.vClienteString;
if (compareValue != null) {
int spinnerPosition = adapter.getPosition(compareValue);
spnClientes.setSelection(spinnerPosition);
}
2.
spnClientes.setSelection(clientes.indexOf(this.vClienteString));
Will I have to do a method that will compare by Cursor
to generate Spinner
, or does it have some simple form like the ones above?