Lucams, thanks for your response, ok, so now i change the imageView for a button created using code. The question is, how can I modify a variable by clicking on the new buttons created. I need to create 100 buttons, and depending on which button I press, a variable is going to change its state. What I don't know is how to relate a code to modify a variable to the click event of that new button created by code.