I am using the following code to grab the selected value in the spinner:
cbFormato.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View v, int posicao, long id) {
//pega nome pela posição
formatoSelecionado = parent.getItemAtPosition(posicao).toString();
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
When I use the code below to show the value that he took the spinner returns the value: Circular
The code to return value of spinner:
Toast.makeText(AppTubulao.this, "Circular: " + formatoSelecionado, Toast.LENGTH_LONG).show();
The problem is when I test the value of the spinner in the same code below it does not recognize the value, ie the value Circular he shows me in Toast is not the same as the “Circular” if that is the test
if (formatoSelecionado == "Circular")
{
Toast.makeText(AppTubulao.this, "Circular: " + formatoSelecionado, Toast.LENGTH_LONG).show();
}
He did not enter the if statement
Assuming they really are set to the same value, the following should evaluate to true.