Reference drawable by name
I have a database holding a lot of static data for my current application. One of the tables in the database gives various information about a list of items. It would make sense for it to hold a reference to the graphic for each item, too. The graphics are stored in a drawable folder and referenced by R.drawable in the application. Am I abl开发者_Python百科e to reference them by their name so that I can store the names as strings in the database? If not, is there an obvious method for doing this that I'm missing?
Am I able to reference them by their name so that I can store the names as strings in the database?
Yes. Take a look at this answer:
Android and getting a view with id cast as a string
精彩评论