最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android RadioButton單選框的使用方法

 更新時(shí)間:2013年04月21日 10:49:31   作者:  
本篇文章小編為大家介紹,Android RadioButton單選框的使用方法。需要的朋友參考下

復(fù)制代碼 代碼如下:

public class MainActivity extends Activity {

 public RadioGroup mRadioGroup1;
 public RadioButton mRadio1, mRadio2;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  mRadioGroup1 = (RadioGroup) findViewById(R.id.gendergroup);
  mRadio1 = (RadioButton) findViewById(R.id.girl);
  mRadio2 = (RadioButton) findViewById(R.id.boy);
  mRadioGroup1.setOnCheckedChangeListener(radiogpchange);

 }

 private RadioGroup.OnCheckedChangeListener radiogpchange = new RadioGroup.OnCheckedChangeListener() {
  @Override
  public void onCheckedChanged(RadioGroup group, int checkedId) {
   if (checkedId == mRadio1.getId()) {
    Toast.makeText(getApplicationContext(), "女孩", 1).show();
   } else if (checkedId == mRadio2.getId()) {
    Toast.makeText(getApplicationContext(), "男孩", 1).show();
   }
  }
 };
}


RadioButton:就像是C#中的Radio控件,可以為控件設(shè)置Group,每個(gè)Group中的項(xiàng)只能選擇一項(xiàng);
復(fù)制代碼 代碼如下:

    <RadioGroup

        android:id="@+id/gendergroup"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:orientation="vertical" >

        <RadioButton

            android:id="@+id/girl"

            android:layout_width="fill_parent"

            android:layout_height="wrap_content"

            android:text="@string/girl" />

        <RadioButton

            android:id="@+id/boy"

            android:layout_width="fill_parent"

            android:layout_height="wrap_content"

            android:text="@string/boy" />

    </RadioGroup>

相關(guān)文章

最新評(píng)論

平定县| 洪洞县| 龙岩市| 东兴市| 仪征市| 临西县| 云林县| 文安县| 白朗县| 通河县| 鱼台县| 弥勒县| 张家港市| 汝阳县| 无锡市| 方正县| 峡江县| 左云县| 中山市| 定南县| 特克斯县| 鲁甸县| 井研县| 来安县| 十堰市| 铜川市| 阜新市| 南皮县| 彭水| 揭西县| 南部县| 孝昌县| 河北区| 周口市| 鄂尔多斯市| 临澧县| 兴海县| 宁晋县| 乐至县| 清涧县| 东海县|