java - Using variable to specify the R object -
i'm new java. pardon me asking such simple question.
to set background-image of view, can by
int thebutton = r.drawable.button1; button.setbackgroundresource(thebutton);
but how can done if want use variable specify r object?
int = 1; int thebutton = r.drawable["button"+a]; //this i'll in javascript... button.setbackgroundresource(thebutton);
try :
string variable="button" + a; int button = getresources().getidentifier(variable, "drawable", getpackagename()); //whatever want do..
Comments
Post a Comment