I'm having a problem adding function to the buttons I created dynamically
What I'm trying to do is I have a house I can set different types of room like BEDROOM, KITCHEN, GARAGE
etc represented as BUTTONS
and then each room has different types of appliances and others stuff which I can also set and also represent by BUTTONS
. The problem is, some users have different number of ROOMS
, some have 2 BEDROOMS
or 3 so I have to make the BUTTONS
for the rooms dynamic and add different function to each BUTTON
. How can I implement this?
for example:
Button room = new Button(this);
room.setText("Bedroom");
room.setID(1);
/* set function for this button like change the textView or add numbers */
and then when I click the button again to add bedroom it will create a new BEDROOM
but with a different function. Is that possible?