RadioGroup和RadioButton 的使用(Activity)
public class RadioText extend Activity
{
private RadioGroup genderGroup =null;
private RadioButton vsButton=null;
private RadioButton nsButton=null;
public void onCreate(Bundle saveIntstanceState)
{
super.onCreate(saveIntstancestate);
setContentView(R.layout.main2);
genderGroup=(RadioGroup)findViewById(R.id.genderGroup);
vsButton=(RadioButton)findViewById(R.id.vsButton);
nsButton=(RadioButton)findViewById(R.id.nsButton);
genderGroup.setOncheckedChangeListener(new RadioGroup.OnCheckedListener())
{
public void onCheckedChanged(RadioGroup group, int checkedId)
{
if(vsButton.getId()==checkedId)
{
Toast.makeText(RadioText.this,"vs",Toast.LENGTH_SHORT);
}
else if(nsButton.getId()==checkeId)
{
system.out.println("ns");
}
}
}
}

浙公网安备 33010602011771号