java - Refer to an object by using a name in a string android -


i want able use object in java using names stored in variables. example :

string[] str={"name1","name2"}; button name1 = (button) findviewbyid(r.id.but1); button name2 = (button) findviewbyid(r.id.but2);  //what want : instead of name1.settext("text");  //to use button.str[0].settext("text"); 

why not use map ?

map<string,button> buttons = new hashmap<string,button>(); buttons.put("buttona", new button()); buttons.get("buttona");  // gets button... 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -