网友通过本文主要向大家介绍了radiobutton,radiobutton用法,radiobutton选中事件,android radiobutton,radiobutton去掉圆圈等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
RadioButton与CheckBox,radiobutton
笔者长期从事于数据库的开发,算了,不提当年了,因为一直用的是小语种(PowerBuilder),还是来说说这两个最常见的控件吧!
RadioButton(单选)和CheckBox(多选)publicclassCheckboxAndRadioBoxActivityextendsAppCompatActivityimplementsCompoundButton.OnCheckedChangeListener,RadioGroup.OnCheckedChangeListener{privateRadioGroup rg_sex;privateCheckBox cb_swimming;privateCheckBox cb_running;privateCheckBox cb_study;privateList<String> hobby =newArrayList<>();@Overrideprotectedvoid onCreate(@NullableBundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_checkbox_and_radiobox);rg_sex =(RadioGroup) findViewById(R.id.rg_sex);cb_swimming =(CheckBox) findViewById(R.id.cb_swimming);cb_running =(CheckBox) findViewById(R.id.cb_running);cb_study =(CheckBox) findViewById(R.id.cb_study);rg_sex.setOnCheckedChangeListener(this);cb_swimming.setOnCheckedChangeListener(this);cb_running.setOnCheckedChangeListener(this);cb_study.setOnCheckedChangeListener(this);}@Overridepublicvoid onCheckedChanged(CompoundButton buttonView,boolean isChecked){switch(buttonView.getId()){case R.id.cb_swimming:if(isChecked){hobby.add("游泳");}else{hobby.remove("游泳");}break

