赞
踩
mAdapter = new SimpleAdapter(this, mp3list,
R.layout.music_list_item_layout, new String[] { “title”, “Artist”, “duration” },
new int[] { R.id.music_title, R.id.music_Artist, R.id.music_duration });
mMusiclist.setAdapter(mAdapter);
}
实现效果如图:
![](https://img-blog.csdn.net/201305081947
56502)
需求2:点击列表的每一项,启动一个服务来播放音乐
1. 注册条目点击监听器OnItemClickListener
2. 定义一个实现OnItemClickListener接口的内部类
3. 定义一个继承Service的服务类PlayerServie
1. 注册条目点击监听器OnItemClickListener
mMusiclist = (ListView) findViewById(R.id.music_list);
mMusiclist.setOnItemClickListener(new MusicListItemClickListener());
mp3Infos = getMp3Infos();
setListAdpter(getMp3Infos());
2. 定义一个实现OnItemClickListener接口的内部类
private class MusicListItemClickListener impleme
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。