Skip to content Skip to sidebar Skip to footer

Accesing To A Drawable Through Its Name In Android

I'm developing an app thant handles a SQLite database. I just get some information from it and show it in a list of CardViews. Each CardView basically displays the name, the age an

Solution 1:

is there anyway to do something like getDrawable("name_of_the_file.png"); or anything similar?

No.

Or is there any way to get the R.drawable.id through the name of the file?

Call getIdentifier() on a Resources object to retrieve the numeric R value given the package, resource type (e.g., "drawable"), and resource name (e.g., "example").

Post a Comment for "Accesing To A Drawable Through Its Name In Android"