public class MainHelloRadioGroup extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final RadioButton radio_red = (RadioButton) findViewById(R.id.radio_red); final RadioButton radio_blue = (RadioButton) findViewById(R.id.radio_blue); OnClickListener ocl = new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MainHelloRadioGroup.this, ((RadioButton)v).getText(), Toast.LENGTH_SHORT).show(); } }; radio_red.setOnClickListener(ocl); radio_blue.setOnClickListener(ocl); } }
radioGroup的按键监控另一种写法
最新推荐文章于 2022-03-23 17:06:04 发布