选择Spinner中的Song,然后播放Android开发的歌曲

问题描述

| 我在以下方面遇到了麻烦: 我有一个带有不同歌曲的微调器。我想做的是,当您从微调器中选择一首歌曲时,媒体播放器将播放这些歌曲。我了解如何进行媒体播放器编码,但无法链接它。我需要播放器可以使用的每首歌或参考ID的某种价值吗?谢谢。 我拥有的代码(仅微调器):
package com.example.spinnertutorial;
公共类SpinnerTutorial扩展Activity {     /** 在第一次创建活动时调用。 * /
String[] spinnerItems = {
        \"Song 1\",\"Song 2\",\"Song 3\",\"Song 4\",\"Song 5\"
};



Spinner sp;

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

    ArrayAdapter<String> adapter = 
        new ArrayAdapter<String> (this,android.R.layout.simple_spinner_dropdown_item,spinnerItems);

    sp = (Spinner)findViewById(R.id.spinner1);
    sp.setAdapter(adapter);

    sp.setOnItemSelectedListener(new OnItemSelectedListener(){

        public void onItemSelected(AdapterView<?> arg0,View arg1,int arg2,long arg3){
            int item = sp.getSelectedItemPosition();
            Toast.makeText(getBaseContext(),\"You have selected the playlist: \" +spinnerItems[ item],Toast.LENGTH_SHORT).show();
        }

        public void onNothingSelected(AdapterView<?> arg0){
        }
    });
} }     

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)