I have their name as String which is in drawable folder. How can I access to drawable folder and pass drawable resource to change the Icon View.
val iconList = ["ic_apple","ic_banana","ic_melon"]
and ic_apple.png
, ic_banana.png
, ic_melon.png
in my drawable folder.
Like, there was this with java's code.
String name = "your_drawable";
int id = getResources().getIdentifier(name, "drawable", getPackageName());
Drawable drawable = getResources().getDrawable(id);
view.setBackground(drawable)