今天对新闻列表中新闻的图片优化,比对之后决定使用网络图片地址,这里需要导入一些必要的包,
从而实现获取网络图片在列表中进行显示。
app中的build.grade中添加依赖:
implementation 'com.github.bumptech.glide:glide:4.11.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
之后导入必要包后使用:
Glide.with(mContext).load(img.trim()).into(holder.img);
因为使用的Fragment所以使用Context,在Activity中是当下Activity的命名,hoder.img是网络图片地址。
今天虽然内容少,但是确实费劲,走了岔路,使用了几种过时的方法。
明天继续努力。