Android 带ListView的音乐播放器
2010-09-06 08:19:00 来源:WEB开发网核心提示:IllegalStateException, IOException{Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,String.valueOf(arg3));TextView tv = (TextView) fin
IllegalStateException, IOException{
Uri uri = Uri.withAppendedPath(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
String.valueOf(arg3));
TextView tv = (TextView) findViewById(R.id.name);
tv.setText(uri.toString());
mp.release();
mp = MediaPlayer.create(this, uri);
mp.start();
}
list.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
try {
playMusic(arg3);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
因为这是个音乐播放器 界面也没什么特别之处 就此略过 只有一个关于所有音乐文件的ListView
done!
更多精彩
赞助商链接