If you want the buttons to do different things, you could activate OnClickListener, set b.setOnClickListener(this)in a loop and add something like
@Override
public onClick(View v)
{
String sTag = (String) v.getTag();
if (sTag.equals("button1"))
{
}
else if (sTag.equals("button2"))
{
}
}
to handle clicks.
And I'm editing this here because the lack of line breaks makes comments ambiguous:
int iBtnID = v.getId();
switch (iBtnID)
{
case 101:
break;
case 102:
break;
}
source
share