"If item" tal "is selected from spinner1, then item" tal2 "from spinner2 is selected" how to do an if there?

-1
public void Spinner1() {
    Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.curso_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner1.setAdapter(adapter);

}

public void Spinner2() {
    Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.turma_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner2.setAdapter(adapter);

}

public void Spinner3() {
    Spinner spinner3 = (Spinner) findViewById(R.id.spinner3);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.periodo_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner3.setAdapter(adapter);

    if ("Redes de Computadores".equals(R.array.curso_array)) {
        ;
    }
}
    
asked by anonymous 29.03.2014 / 23:30

1 answer

2

When you set the spinner, put this code together to define a listener that runs every time the selection changes.

    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
        // Aqui você checa se a nova seleção é o curso de redes.
        if (id == ID_DO_CURSO_REDES){
            // se for, definimos a seleção do spinner2 (periodo) para tarde.
            final spinner2 = (Spinner) findViewById(R.id.spinner2);
            spinner2.setSelection(ID_DO_PERIODO_TARDE);
        }
    }
    });
    
30.03.2014 / 21:08