1. Radio
. RadioGroup can be their different RadioButton, set up a limit with a Radio button group , with a RadioGroup Group button can only make a single choice ( multiple choice ).
<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 Button is a variety of UI controls in one of the most commonly used , it is also the most popular Android development one of the controls , the user can touch it to trigger a series of events , you know a no click event of the Button is no sense , because the user's fixed point of thinking is to go see it !
android: id = "@ + id / btncal"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: text = " computing " />
. 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) {
}
}
没有评论:
发表评论