check Radio Group - Android User Interface

Android examples for User Interface:RadioButton

Description

check Radio Group

Demo Code


//package com.java2s;

import android.widget.RadioButton;
import android.widget.RadioGroup;

public class Main {
    public static void checkRadioGroup(RadioGroup radioGroup,
            String selectedRadioText) {
        for (int i = 0; i < radioGroup.getChildCount(); i++) {
            RadioButton radio = (RadioButton) radioGroup.getChildAt(i);
            if (radio.getText().equals(selectedRadioText)) {
                radioGroup.check(radio.getId());
                break;
            }/*from ww w.j a  v a  2s. c  o m*/
        }
    }
}

Related Tutorials