Good, I have a spinner
with the following values: Teacher and Student, my question is, how do I do it so that if the person chose Professor of the spinner direct him to a activity
, but if you chose Student from spinner
address another activity
, so that my question is more understandable I leave my code
Spinner tipuus;
String[] tipos={"Elija una opción","Alumno","Profesor"};
//---------------------------
tipuus= (Spinner) findViewById(R.id.spntipusu);
//---------------------------
ArrayAdapter<String> listatipusu=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,tipos);
tipuus.setAdapter(listatipusu);
//---------------------------
btnregistrar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (tipuus.equals("Alumno")){
Toast.makeText(LoginActivity.this, "Usted a escogido alumno", Toast.LENGTH_SHORT).show();
}if (tipuus.equals("Profesor")){
Toast.makeText(LoginActivity.this, "Usted a escogido profesor", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(LoginActivity.this, "Usted no ha escogido un tipo de usuario", Toast.LENGTH_SHORT).show();
}
}
});
I know that the tipuus.equals("Alumno")
part is wrong, I would like to know what the code would be like to do what I ask. Thanks