将MySql数据库中存储的图像名称转换为Android中的Drawable

将MySql数据库中存储的图像名称转换为Android中的Drawable,android,mysql,drawable,Android,Mysql,Drawable,我有这段代码。我的图像名存储在MySql数据库中,现在我想将其转换为可绘制的,以用于标题滑块 photo字段是数据库中的图像字段,about是存储在drawable文件夹中的图像名称,但我希望数据库中的图像存储在R.drawable.images中 for (int i=0;i<array.length();i++) { JSONObject object = array.getJSONObject(i); String name = object.getString("n

我有这段代码。我的图像名存储在MySql数据库中,现在我想将其转换为可绘制的,以用于标题滑块

photo字段是数据库中的图像字段,about是存储在drawable文件夹中的图像名称,但我希望数据库中的图像存储在R.drawable.images中

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);
}

如果您有图像名称,这意味着图像存在于设备的某个位置-对吗? 如果是这样的话

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");

File image = new  File(photo);

//check if the image really exsist
if(image.exists()){

    Bitmap bm = BitmapFactory.decodeFile(image.getAbsolutePath());

    //.... now do whatever you want to do with it
    //you can use setImageBitmap(bm); to display the image on an ImageView 
}

你想让android通过名字谷歌搜索查询你为什么只需要drwable?您可以将图像设置为“从路径”