You can try this function
: -
private Drawable getDrawable(String source)
{
Drawable drawable;
int sourceId =
getApplicationContext()
.getResources()
.getIdentifier(source, "drawable", getPackageName());
drawable = getApplicationContext().getResources().getDrawable(dourceId);
drawable.setBounds(0,0,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight());
return drawable;
}
function implementation
: -
/*If you can get the JSON response same as the name of the image or set the name of the image as per your response this will work very efficiently*/
imageView.setImageDrawable(getDrawable("sunny"));//this will return a drawable whose name is sunny
Оставить комментарий, если возникнут проблемы.