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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -