I have to dynamically create 4 Buttons and I have to generate dynamically their id, something like:
for(int i = 1; i <= 4; i++){
Button button = new Button(activity);
// i need something here to turn this string into an int;
button.setId("button" + i)
}
I know how to dynamically get the id of an existing view:
getResources().getIdentifier("button2", "button", getPackageName())
What I don't know, is how to generate the id dynamically.
I looked on the internet but I didn't find in anything.
I need something like:
int id = getResources().setIdentifier("button2", "button", getPackageName());
button.setid(id);
Thank you in advance.