【发布时间】:2017-07-05 04:56:50
【问题描述】:
我是 Android 开发新手,我正在尝试构建一个音乐播放器。为了在 RecyclerView 中添加歌曲数据,我创建了一个 ArrayList (thisList),其中包含包括专辑封面在内的歌曲数据,但我不知道如何将图像添加到列表中:(
if(musicCursor!=null && musicCursor.moveToFirst()){
//get columns
int titleColumn = musicCursor.getColumnIndex
(android.provider.MediaStore.Audio.Media.TITLE);
int idColumn = musicCursor.getColumnIndex
(android.provider.MediaStore.Audio.Media._ID);
int artistColumn = musicCursor.getColumnIndex
(android.provider.MediaStore.Audio.Media.ARTIST);
int albumColumn = musicCursor.getColumnIndex
(MediaStore.Audio.Media.ALBUM);
int albumArtColumn = musicCursor.getColumnIndex
(android.provider.MediaStore.Audio.Albums.ALBUM_ART);
//add songs to list
do {
long thisId = musicCursor.getLong(idColumn);
String thisTitle = musicCursor.getString(titleColumn);
String thisArtist = musicCursor.getString(artistColumn);
String thisAlbum = musicCursor.getString(albumColumn);
//ImageView thisAlbumArt = musicCursor. ????
theList.add(newSong(thisId,thisTitle,
thisArtist,thisAlbum,thisAlbumArt));
}
while (musicCursor.moveToNext());
}
【问题讨论】:
标签: java android android-cursor