最新国产好看的视频,伊人天堂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)文章

最新評論

富裕县| 礼泉县| 抚顺市| 稷山县| 凌云县| 额尔古纳市| 当雄县| 龙山县| 通渭县| 永丰县| 苍梧县| 西安市| 城步| 天柱县| 建平县| 修武县| 尉犁县| 隆化县| 平湖市| 青田县| 富阳市| 宁波市| 伊春市| 信宜市| 图木舒克市| 望奎县| 平定县| 开原市| 台北市| 巫山县| 汝阳县| 太康县| 秦皇岛市| 台安县| 峨眉山市| 潞西市| 兰西县| 永靖县| 宜阳县| 瓦房店市| 靖远县|