首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

RadioBox单选框施用

2012-07-28 
RadioBox单选框应用一、RadioBox单选框的使用?public RadioGroup mRadioGroup1public RadioButton mRadio1

RadioBox单选框应用

一、RadioBox单选框的使用

?

public RadioGroup mRadioGroup1;public RadioButton mRadio1, mRadio2;public Button button1;/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.radio);button1 = (Button) findViewById(R.id.button1);mRadioGroup1 = (RadioGroup) findViewById(R.id.radioGroup1);mRadio1 = (RadioButton) findViewById(R.id.radio1);mRadio2 = (RadioButton) findViewById(R.id.radio2);/* RadioGroup用OnCheckedChangeListener来执行 */mRadioGroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {public void onCheckedChanged(RadioGroup group, int checkedId) {// TODO Auto-generated method stubif (checkedId == mRadio1.getId()) {/* 把mRadio1的内容传到mTextView1 */toast(mRadio1.getText().toString());} else if (checkedId == mRadio2.getId()) {/* 把mRadio2的内容传到mTextView1 */toast(mRadio2.getText().toString());}}});button1.setOnClickListener(new OnClickListener(){public void onClick(View v) {mRadioGroup1.clearCheck();}});}public void toast(String str) {Toast.makeText(RadioBoxNew.this, str, Toast.LENGTH_LONG).show();}
?


RadioBox单选框施用
?
RadioBox单选框施用

热点排行