I have a situation in an app I'm making where I have an activity that has 15 buttons and a string[] that contains 15 strings. I'm looking for an easy way to assign each string in the string[] to its corresponding button. I was hoping I could somehow do something like:
for(int i; i<myStringArray.length; i++){
String ref = "btn" + (i + 1);
ref.setText(resultString[i]);
}
where all the buttons are labeled "btn1", "btn2", etc so that they could all be accessed with the string "ref". Obviously this doesn't work so I was wondering if there was another way of doing something similar to this instead of doing:
btn1.setText(resultString[0]);
btn2.setText(resultString[1]);
btn3.setText(resultString[2]);
...
thanks for the help!