Android - Spinner imbriqué

AmineJava Messages postés 15 Date d'inscription dimanche 14 décembre 2014 Statut Membre Dernière intervention 17 mai 2015 - Modifié par BunoCS le 16/04/2015 à 11:33
voila mon code source pour trois spinner:


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import com.example.dell.pgeacceuil.CustomOnItemSelectedListener.CustomOnItemSelectedListener;


/**


* Created by DELL on 06/04/2015.

*/
public class rechercheav extends Activity {


        private Spinner spinner1, spinner2, spinner3;
        private Button button;




        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.advancedsearch);


           //addListenerOnCheckbox1();
           //addListenerOnCheckbox2();
            spinner1();
            Spinner2();
            spinner3();
            addListenerOnButton();
            //addListenerOnSpinnerItemSelection();

        }
        //Spinner 01
        public void spinner1() {


            spinner1 = (Spinner) findViewById(R.id.spinner1);
            List<String> list = new ArrayList<String>();
            list.add("Public");
            list.add("Privé");


            ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
                    (this, android.R.layout.simple_spinner_item, list);

            dataAdapter.setDropDownViewResource
                    (android.R.layout.simple_list_item_single_choice);
            spinner1.setAdapter(dataAdapter);

        }


        // spinner 03
        public void spinner3() {


        spinner3 = (Spinner) findViewById(R.id.spinner3);
        List<String> list = new ArrayList<String>();
        list.add("Clinique");
        list.add("Cabinet");


        ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
                (this,android.R.layout.simple_spinner_item ,list);

        dataAdapter.setDropDownViewResource
                (android.R.layout.simple_list_item_single_choice);

        spinner3.setAdapter(dataAdapter);
    }


    // spinner 02
    public void Spinner2() {

        spinner2 = (Spinner) findViewById(R.id.spinner2);
        List<String> list = new ArrayList<String>();
        list.add("5km");
        list.add("10km");
        list.add("15km");
        list.add("20km");
        list.add("25km");


        ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
                (this,android.R.layout.simple_spinner_item, list);

        dataAdapter.setDropDownViewResource
                (android.R.layout.simple_list_item_single_choice);

        spinner2.setAdapter(dataAdapter);
    }

        // get the selected dropdown list value
        public void addListenerOnButton() {
           
           //spin
            spinner1 = (Spinner) findViewById(R.id.spinner1);
            spinner2 = (Spinner) findViewById(R.id.spinner2);
            spinner3 = (Spinner) findViewById(R.id.spinner3);

            button   = (Button) findViewById(R.id.button);

            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {

                    


                    
                    Toast.makeText(rechercheav.this,
                            "OnClickListener : " +
                                    "\nSpinner 1 : " +   String.valueOf(spinner1.getSelectedItem()) +
                                    "\nSpinner 2 : " + String.valueOf(spinner2.getSelectedItem()) +
                                    "\nSpinner 3 : " + String.valueOf(spinner3.getSelectedItem()),

                            Toast.LENGTH_SHORT).show();
                }

            });
        }
    }


Mon probléme c'est que je trouve pas comment faire pour que, quand l'user choisis "privé" il m'affiche un certains(ex:clinique/cabinet) choix mais que si il choisis public il m'affiche un autre choix différent (ex:hôpital/dispensaire)
Merci