1
I am developing an application Android, and in it I have a Spinner
and from the choice that the user makes in this Spinner
it goes to 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);
}
}
}
});
}
At first it worked, but when you have more than one option, as shown in the code above, it enters the first if
and even if he’s wrong he gives the result of the first if
.
Thank you very much, you simplified it well, I was seeing more difficult ways. Thank you
– Leonardo Pinheiro