<RadioGroup
android:id="@+id/function_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toStartOf="@+id/imageView2"
android:layout_toLeftOf="@+id/imageView2">
<RadioButton
android:text="肤色手势分割"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton" />
<RadioButton
android:text="红色对象识别"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton2"/>
<RadioButton
android:text="特征匹配定位"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton3" />
</RadioGroup>
private RadioGroup function=null;
private RadioButton radio1=null;
private RadioButton radio2=null;
private RadioButton radio3=null;
private Boolean bIsRun1 = false;
private Boolean bIsRun2 = false;
private Boolean bIsRun3 = false;
function =(RadioGroup) super.findViewById(R.id.function_group);
radio1 =(RadioButton) super.findViewById(R.id.radioButton);
radio2 =(RadioButton) super.findViewById(R.id.radioButton2);
radio3 =(RadioButton) super.findViewById(R.id.radioButton3);
function.setOnCheckedChangeListener(new OnCheckedChangeListenerImp());
private class OnCheckedChangeListenerImp implements RadioGroup.OnCheckedChangeListener {
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (MainActivity.this.radio1.getId() == checkedId){
bIsRun1 = true;
bIsRun2 = false;
bIsRun3 = false;
} else if(MainActivity.this.radio2.getId() == checkedId){
bIsRun1 = false;
bIsRun2 = true;
bIsRun3 = false;
}
else if(MainActivity.this.radio3.getId() == checkedId){
bIsRun1 = false;
bIsRun2 = false;
bIsRun3 = true;
}
}
}