在Glide库中加载字符串本地地址

问题描述 投票:0回答:1

我有一个数据库,我可以在下面设置图片地址。字符串 这样 "R.mipmap.image".但如何使用Glide库中的这个字符串来打开一张图片?(只能用 字符串 本地图像地址)

Glide.with(this).load(???).into(image);
android android-glide glide
1个回答
0
投票

你可以使用标识符来获取想要的图片

Resources res = context.getResources();
return res.getDrawable(res.getIdentifier(idName, "drawable", context.getPackageName()));
© www.soinside.com 2019 - 2024. All rights reserved.