十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
//activity_main.xml
//strings.xml
RadioGroup Hello world! Settings 男 女
//MainActivity.java
package com.vincentlin.radiogroup; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.RadioGroup; import android.widget.RadioGroup.OnCheckedChangeListener; public class MainActivity extends Activity implements OnCheckedChangeListener{ private RadioGroup rg; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); rg = (RadioGroup) findViewById(R.id.radioGroup1); //实现RadionGroup的事件监听 rg.setOnCheckedChangeListener( this); } @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.radio0: Log.i("tag","当前为男性"); break; case R.id.radio1: Log.i("tag","当前为女性"); break; default: break; } } }