add Radio Group to TableLayout - Android android.widget

Android examples for android.widget:TableLayout

Description

add Radio Group to TableLayout

Demo Code

import android.content.Context;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TableLayout;

public class Main {

  public static RadioGroup addRadioGroup(Context ctx, TableLayout parent, String... options) {
    RadioGroup rg = new RadioGroup(ctx);

    for (String o : options) {
      RadioButton rb = new RadioButton(ctx);
      rb.setText(o);/* ww w.j ava2 s.co  m*/
      rg.addView(rb);
    }
    parent.addView(rg);
    return rg;
  }

}

Related Tutorials