I used a loop to create some dynamically generated buttons and in the same loop, I defined OnClickListeners.
summerized code:
for (int j=0; j