【发布时间】:2018-10-02 04:29:32
【问题描述】:
我有这段代码。我的图像名称存储在 MySql 数据库中,现在我想将其转换为可绘制的横幅滑块。
“photo”字段是数据库中的图像字段,“about”是存储在可绘制文件夹中的图像名称,但我想要 R.drawable 中数据库中的图片。“images_stored_in_db”。
for (int i=0;i<array.length();i++)
{
JSONObject object = array.getJSONObject(i);
String name = object.getString("name");
String email = object.getString("email");
String pass = object.getString("password");
String photo = Connection.API + object.get("photo");
banners.add(new DrawableBanner(R.drawable.about));
ShowItem item = new ShowItem(name,email,pass,photo);
RegisterContent.ITEMS.add(item);
}
【问题讨论】:
-
你要
android get drawable by namegoogle搜索查询 -
为什么你只需要drwable?您可以将图像设置为来自路径