android - Need Integer resource id of drawable resources dynamically -


i need set notification image icon dynamically , name passed class dynamically. , need set builder.setsmallicon(int res_id). googled , people have used example of setdrawableimage() have seen post , , accordingly implemented in code.

   //blah blah lines of code    string uri = "@drawable/a";    int imageresource = con.getresources().getidentifier(uri,null, con.getpackagename());    drawable res = con.getresources().getdrawable(imageresource);    builder.setsmallicon(res);    //blah blah code lines 

of course, shows error because setsmallicon() requires integer passed it. con context passed constructor. have seen how set image drawable dynamically in android? post

of course, shows error because setsmallicon() requires integer passed it.

you have desired integer. named imageresource. pass imageresource setsmallicon().


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -