In my Android application, I have a sound that I want to play when a certain choice was made from the counter, but I want it to play when the user really makes the right choice (or right after it). My problem is that, although the sound is played when they make the right choice, while that choice remains selected, it also plays every time the application starts, when it should ONLY play at the time it was selected. Here is the code that I have now:
fitnessSpinner = (Spinner) findViewById(R.id.fitness_spinner); ArrayAdapter adapter4 = ArrayAdapter.createFromResource( this, R.array.fitness_array, android.R.layout.simple_spinner_item); adapter4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); fitnessSpinner.setAdapter(adapter4); fitnessSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long i) { Log.d("test", "p: " + position + " " + i); if(position == 0) {
How to make the sound stop playing when the application starts? Should I wrap the whole fitnessSpinner.setOnItemSelectedListener ... inside some type of change selection, if such a thing exists?
source share