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");

   }

 

   } 

  

   }  

}

posted @ 2011-09-04 18:49  WangWeiDa  阅读(350)  评论(0编辑  收藏  举报