Hi,

I am currently doing an application which will play a sound from a
selection via a spinner. I've tried many ways but I still cannot get
it to play a sound.

Here is my code for the constraints and spinner.

// List-based Constants
        public static final int HAPPY = 0;
        public static final int LAUGHTER = 1;

//code for spinner
Spinner s = (Spinner) findViewById(R.id.SoundSpinner);
                ArrayAdapter adapter = ArrayAdapter.createFromResource
(
                       this, R.array.Sounds,
android.R.layout.simple_spinner_item);
                adapter.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
                s.setAdapter(adapter);
                s.setOnItemSelectedListener(OnItemSelectedListener);

                Spinner.OnItemSelectedListener OnItemSelectedListerner
= new
                OnItemSelectedListener() {
                        public void onItemSelected(AdapterView parent,
View v, int idNum,
                long id) {


                                                        switch (idNum){
                                case HAPPY:
                                  Music.play(this, R.raw.happy);
                                                break;
                                        case LAUGHTER:
                                                Music.play(this, 
R.raw.laughter);
                                                break;

                             }
                         }
                         public void onNothingSelected(AdapterView
arg0) {}
                     };

I know android's spinner does not respond to setOnItemClickListener.
However, when I changed it to onClick, I get confused with the code
and the application quits by itself when I run it on the emulator. Can
anyone help me? Thank you so much! (:

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to