I'm developing an Android application, and in it I have a Spinner
and from the choice the user makes in that Spinner
it goes to a certain page.
I had done so:
//Acionando_Items_no_Spinner
public void addListenerOnSpinnerItemSelection()
{
spinner1 = (Spinner) findViewById(R.id.spinner1);
spinner1.setOnItemSelectedListener(new MyOnItemSelectedListener());
}
public void addListenerOnButton()
{
spinner1 = (Spinner) findViewById(R.id.spinner1);//Informação_Do_Spinner
button = (Button) findViewById(R.id.button);//Informação_Do_Botão
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
//Escolha_da_pagina
if(String.valueOf("São Paulo") != null){
setContentView(R.layout.activity_page2);
}else{
if(String.valueOf("Rio de Janeiro") != null){
setContentView(R.layout.activity_page3);
}
}
}
});
}
In the beginning it worked, but when it has more than one option, as shown in the code above, it goes into the first if
and even if it is wrong it gives the result of the first if
.