Android 使用Listview将相册艺术加载到Glide中
加载相册艺术的代码Android 使用Listview将相册艺术加载到Glide中,android,listview,android-glide,Android,Listview,Android Glide,加载相册艺术的代码 if(cursor != null && cursor.moveToFirst()){ int titleColumn = cursor.getColumnIndex(MediaStore.Audio.Media.TITLE); int idColumn = cursor.getColumnIndex(MediaStore.Audio.Media._ID); int artistColumn = cur
if(cursor != null && cursor.moveToFirst()){
int titleColumn = cursor.getColumnIndex(MediaStore.Audio.Media.TITLE);
int idColumn = cursor.getColumnIndex(MediaStore.Audio.Media._ID);
int artistColumn = cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST);
int albumColumn = cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM);
long albumID = cursor.getColumnIndex(MediaStore.Audio.Albums.ALBUM_ID);
do {
long thisID = cursor.getLong(idColumn);
String thisTitle = cursor.getString(titleColumn);
String thisArtist = cursor.getString(artistColumn);
String thisAlbum = cursor.getString(albumColumn);
Glide.with(this)
.load(albumID)
.asBitmap()
.into() //How do I return a value?
medialist.add(new SongInfo(thisID, thisTitle, thisArtist, thisAlbum, //Bitmap variable));
}
while (cursor.moveToNext());
我正在尝试使用Glide将相册艺术加载到listview中。然而,我在工作中遇到了麻烦
添加(新歌曲信息(…)
你做错了:
使用以下命令:
medialist.add(new SongInfo(thisID, thisTitle, thisArtist, thisAlbum,albumID));
现在,在listview适配器类中,获取medialist和glide方法:
定义:
现在在适配器的构造函数中:
public CustomAdapter(List<Medialist> items, Context context) {
medialist= items;
this.con = context;
}
Glide.with(con)
.load(medialist.getAlbumID)
.asBitmap()
.into(imageview)
publiccustomadapter(列表项、上下文){
媒体列表=项目;
this.con=上下文;
}
滑翔
.load(medialist.getAlbumID)
.asBitmap()
.into(图像视图)
您做错了:
使用以下命令:
medialist.add(new SongInfo(thisID, thisTitle, thisArtist, thisAlbum,albumID));
现在,在listview适配器类中,获取medialist和glide方法:
定义:
现在在适配器的构造函数中:
public CustomAdapter(List<Medialist> items, Context context) {
medialist= items;
this.con = context;
}
Glide.with(con)
.load(medialist.getAlbumID)
.asBitmap()
.into(imageview)
publiccustomadapter(列表项、上下文){
媒体列表=项目;
this.con=上下文;
}
滑翔
.load(medialist.getAlbumID)
.asBitmap()
.into(图像视图)
hi@Divyesh我无法初始化Glide。在我的适配器类中,它表示unsolve方法,我在Glide之后放置什么。在(..)中,hi@Divyesh我无法初始化Glide。在适配器类中,它表示unsolve方法,我在Glide之后放置什么。在(..)中。