0

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:

enter image description here

But since the RG_list is vertical (because I want all the buttons will be in seperate lines) it looks like that:

enter image description here

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);  
}
TamarG
  • 3,522
  • 12
  • 44
  • 74
  • Are you tried use a custom ListView? maybe it's help you – Aspicas Feb 20 '15 at 15:00
  • No, what is it? can I use it with radio buttons so only one row can be selected? – TamarG Feb 20 '15 at 15:07
  • You have a ListView, using Custom listview you can custom all Appearance on each row on your listview, you can use any object on your listView, radiobuttons, images, text... wait a moment, now I give you a tutorial. – Aspicas Feb 20 '15 at 15:09
  • Thanks! I'll see it tommorrow. – TamarG Feb 20 '15 at 15:13
  • http://www.survivingwithandroid.com/2013/02/android-listview-adapter-imageview.html check that tutorial, here are using Image and two textview but you can use radio buttons and any object using a "custom adapter" – Aspicas Feb 20 '15 at 15:15
  • 1
    If you need more tutorials tell me or you can find on Google using "custom adapter ListView Android" or "custom ListView Android" – Aspicas Feb 20 '15 at 15:16
  • I think this is what you're looking for: http://stackoverflow.com/questions/20456322/preparing-customized-radio-group-type-of-layout – Jorge Mendez Feb 20 '15 at 15:19
  • I give you another tutorial: http://www.android-ios-tutorials.com/android/android-custom-listview-example/ – Aspicas Feb 20 '15 at 15:21

0 Answers0