唐山市住房与城乡建设厅网站,建立健全安全生产责任制的根本目的是,公司网络架构,门户网站衰落的原因RadioButton控件 RadioButton控件是单选按钮控件#xff0c;它继承自Button控件#xff0c;可以直接使用Button控件支持的各种属性和方法。
与普通按钮不同的是#xff0c;RadioButton控件多了一个可以选中的功能#xff0c;能额外指定一个android#xff1a;checked属性… RadioButton控件 RadioButton控件是单选按钮控件它继承自Button控件可以直接使用Button控件支持的各种属性和方法。
与普通按钮不同的是RadioButton控件多了一个可以选中的功能能额外指定一个androidchecked属性该属性可以指定初始状态是否被选中。其实也可以不用指定默认初始状态都不被选中。
RadioButton控件必须和单选框RedioGroup控件一起使用。 RadioButton控件的使用 RadioGroupandroid:idid/radiogroupandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalRadioButtonandroid:idid/oneandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text一年级android:checkedtrue/RadioButtonandroid:idid/twoandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text二年级/RadioButtonandroid:idid/threeandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text三年级//RadioGroup RadioButton控件的选中监听器 //为RadioGroup设置一个事件监听器val radioGroup:RadioGroupfindViewById(R.id.radiogroup)radioGroup.setOnCheckedChangeListener { group, checkedId -val check:RadioButtonfindViewById(checkedId)Toast.makeText(this,${check.text},Toast.LENGTH_SHORT).show()}