I need to create a dynamic radio-button list in my android activity. Every button will contain a text label, and two action buttons, like that:
But since the RG_list is vertical (because I want all the buttons will be in seperate lines) it looks like that:
This is my code:
RG_list = new RadioGroup(this); //create the RadioGroup
RG_list.setOrientation(RadioGroup.VERTICAL);
for ( String text: texts)
{
RadioButton RB_SingelBackupName = new RadioButton(this);
RB_SingelBackupName.setText(text);
RB_SingelBackupName.setButtonDrawable(new StateListDrawable());
RB_SingelBackupName.setCompoundDrawablesWithIntrinsicBounds(0, 0, android.R.drawable.btn_radio, 0);
RG_list.addView(RB_SingelBackupName);
// add delete button
ImageButton button_del = CreateImageButton( this, button_del); // Inner function
button_del.setOnClickListener(new View.OnClickListener() {
/* .... */
} });
RG_list.addView(button_del);
// add share button
ImageButton button_share = CreateImageButton( this, button_share ); // Inner function
button_share .setOnClickListener(new View.OnClickListener() {
/* .... */
} });
RG_list.addView(button_share);
}