0
Am I doing it this way would be correct? The problem is that it is not working as expected follows code:
Here I take the data that comes from a list and the other screen and save it in situation:
situacao = bundle.getString("situacao");
Here I want to set the Spinner component with this option :
spinnerSituacao.setSelection(Integer.parseInt(situacao));
But isn’t it working right what I do? situation is a String that can be "1" or "2".
I added it to the list to be displayed on Spinner this way:
List<String> listaSituacao = new ArrayList<String>();
listaSituacao.add("Ativo");
listaSituacao.add("Desativado");
ArrayAdapter<String> adapterSituacao = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, listaSituacao);
And to take its value that way:
spinnerSituacao.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Situacao = String.valueOf(position + 1);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
What is the expected form??? It is turning into 1 or 0??
– Thiago Luiz Domacoski
I’ll edit young man.....
– Aline
What values are in Spinner?
– ramaral
I just want to set an already certain value that comes from a webservice and set in Spinner this value on the edit screen
– Aline
Try it like this: spinnerSituacao.setSelection( (Integer.parseint(situation)-1 );
– Thiago Luiz Domacoski
Worked beautifully ;)
– Aline
I need to think in a simplified way even. I really hope to improve this my way of programming...
– Aline
This you will pick up with time! It is important to pay attention and try to understand what is happening!!! Debug the application and put some Log, it helps a lot! =)
– Thiago Luiz Domacoski
Thanks you really helped me. = *** Okay.
– Aline