Good afternoon, I have a simple form in my android app, where the user writes name and signs an alert, but in the frequency field of the alert I inserted a spinner (android selectbox) with options of numbers that are strings. / p>
txtFrequencia.setOnItemSelectedListener((AdapterView.OnItemSelectedListener) this);
List<String> frequencia = new ArrayList<String>();
frequencia.add("2");
frequencia.add("4");
frequencia.add("6");
frequencia.add("8");
frequencia.add("10");
frequencia.add("12");
frequencia.add("24");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, frequencia);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
txtFrequencia.setAdapter(dataAdapter);
This is the part where I declare the spinner, but the problem is happening in my class that registers in the database, I'm not sure what to insert into it, I'm using getOnItemSelectedListener () to try to get the value but it's not working, follow the code:
private long loadType() {
Type type = new Type();
millisIdentificador = Calendar.getInstance().getTimeInMillis();
type.setContent("Alerta;" + String.valueOf(millisIdentificador) + ";" + txtNomeAlerta.getText().toString()
+ ";" + (btnTodoDia.isChecked() ? 1 : 0) + ";" + (btnFimdeSemana.isChecked() ? 1 : 0)
+ ";" + Integer.parseInt(txtFrequencia.getOnItemSelectedListener().toString()) + ";"
+ Integer.parseInt(txtQuantComprimidos.getText().toString()) + ";"
+ Integer.parseInt(txtQuantDias.getText().toString()));
type.setComentarCard(0);
type.setCompartilharCard(0);
type.setCurtirCard(0);
return dataStoreType.addType(type);
}
Does anyone have any idea how I can do to put the correct value of the spinner's position.