RadioGroup和RadioButton的使用方法

/*布局文件<RadioGroup><RadioButton/><RadioButton/></RadioGroup><RadioGroup></RadioGroup>
*/
/* java 类*/
RadioGroup rg....;RadioButton rb....;CheckBox cb...;
rg.setOnCheckedChangeListener(new RadioGroup.onCheckedChangeListener(){
	public void onCheckedChanged(RadioGroup rg,int checkedId){
		if(rb.getId()==checkedId){
			Toast.makeText(RadioTest.this,"famale",Toast.LENGTH_SHORT).show();// 桌面提示信息
		}
	}
})

cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
	public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
	if(isChecked){
	//	......
		}
	}
}

 

你可能感兴趣的:(RadioButton)