I am creating buttons programmatically in Android Xamarin (C#) like this:
for(int i = 0; i < 3; i++) {
...
Button b = new Button(this);
b.Click += delegate {
processClick(i);
};
...
}
the processClick method looks like this:
public void processClick(int i) {
... Log("i: " + i);
}
It successfully creates 3 buttons, but if I press any of them, the console log's number 3. The question is, how handle clicked events of programmatically created buttons?