4

I have this spinner with a list of music items. Upon clicking the music items, music will play and stop when user selects any music items.

The question is how to stop the music if user presses the back button?

I have tried to find methods that is called when spinner is closed. Can't seem to find any though. Am I missing anything obvious?

Please help!! thanks

If it matters, my spinner is called from a fragment.

    musicSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> av, View v, int i, long l) {
                Log.v("music spinner","Item selected");
            if (mp.isPlaying())
                mp.stop();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
                Log.v("music spinner","Item not selected");
        }
    });
4

1 回答 1

-2

当用户选择返回按钮的主页按钮时,活动和片段,将onPause在其他方法中得到调用。这可能是检测何时停止音乐的好地方。

于 2013-07-25T01:20:25.527 回答