Every RadioButton
requires a unique ID so, that RadioGroup
can differentiate them. Try this.
RadioGroup group = (RadioGroup)findViewById(R.id.grp);
for(int i = 0; i < 3; i++) {
RadioButton btn = new RadioButton(this);
btn.setId(i); // <- set ID
btn.setText(String.valueOf(i));
group.addView(btn);
}