安卓学习之--UI控件用法 单选 按钮 下拉框
2013-07-31 14:46
429 查看
1。单选
.RadioGroup 可将各自不同的RadioButton ,设限于同一个Radio 按钮组,同一个RadioGroup 组里的按钮,只能做出单一选择(单选题).
.java
按钮 Button是各种UI中最常用的控件之一,它同样也是Android开发中最受欢迎的控件之一,用户可以通过触摸它来触发一系列事件,要知道一个没有点击事件的Button是没有任何意义的,因为使用者的固定思维是见到它就想去点!
<Button
android:id="@+id/btncal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="计算" />
.java
.RadioGroup 可将各自不同的RadioButton ,设限于同一个Radio 按钮组,同一个RadioGroup 组里的按钮,只能做出单一选择(单选题).
<RadioGroup android:id="@+id/group" android:orientation="horizontal"> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="没过5年" android:checked="true" android:id="@+id/rdyear5" /> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="过5年" android:id="@+id/rdyearno5" /> </RadioGroup>
.java
private RadioGroup group; private RadioButton rb1 ; private RadioButton rb2 ; private boolean blflag; group=(RadioGroup) this.findViewById(R.id.group); rb1=(RadioButton) this.findViewById(R.id.rdyear5); rb2=(RadioButton) this.findViewById(R.id.rdyearno5); group.setOnCheckedChangeListener(new checkedlistener()); public class checkedlistener implements RadioGroup.OnCheckedChangeListener{ @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if(checkedId==R.id.rdyear5){ blflag=true; }else if(checkedId==R.id.rdyearno5){ blflag=false; } } }
按钮 Button是各种UI中最常用的控件之一,它同样也是Android开发中最受欢迎的控件之一,用户可以通过触摸它来触发一系列事件,要知道一个没有点击事件的Button是没有任何意义的,因为使用者的固定思维是见到它就想去点!
<Button
android:id="@+id/btncal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="计算" />
.java
Button btncal=(Button) this.findViewById(R.id.btncal); //获取该按钮控件 btncal.setOnClickListener(new listener()); //事件 private class listener implements View.OnClickListener{ @Override public void onClick(View v) { } }
相关文章推荐
- VC单选按钮控件(Radio Button)用法(转)
- VC单选按钮控件(Radio Button)用法
- 安卓开发_单选按钮控件(RadioButton)的简单使用
- UI控件之RadioButton(单选按钮)&Checkbox(复选按钮)
- VC单选按钮控件(Radio Button)用法
- VC单选按钮控件Radio Button用法
- (转)VC单选按钮控件(Radio Button)用法
- VC单选按钮控件(Radio Button)用法
- 安卓控件使用系列10:RadioButton单选按钮的使用
- VC单选按钮控件(Radio Button)用法(转)
- VC单选按钮控件(Radio Button)用法(转)
- VC单选按钮控件(Radio Button)用法
- Android UI控件系列:RadioButton(单选按钮)
- VC单选按钮控件(Radio Button)用法(转)
- Qt学习六:控件三:单选按钮、复选框、列表控件、树控件
- VC单选按钮控件(Radio Button)用法(转)
- Android学习-常见的UI控件 监听按钮的点击事件
- VC单选按钮控件(Radio Button)用法(转)
- VC单选按钮控件(Radio Button)用法
- 安卓控件之单选按钮 (RadioButton和RadioGroup)