所以我想播放我的点击列表,但我不知道我在哪里弄乱了我的代码。我想从我的存储设备(内部或外部,而不是原始设备)中播放它,我试图重命名deftype,但是什么也没发生。
public void Play(){
listView = (ListView) findViewById(R.id.list_item);
arrayList = new ArrayList<>();
getMusic();
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, arrayList);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> AdapterView, View view, int i, long l) {
if (mediaPlayer != null){
mediaPlayer.release();
}
int resID = getResources().getIdentifier(arrayList.get(i),"raw",getPackageName());
mediaPlayer.create(SongsActivity.this,resID);
mediaPlayer.start();
}
});