意义:Android使用RadioGroup内只能用RadioButton,不满足需求中的单选布局要求。
步骤:使用CheckBox,结合checkSign 和 默认全部否定设置,判断checkSign来设置那个checkBox为true来实现效果。
private void updateChoseBox(){ cboxDes.setChecked(false); cboxVoice.setChecked(false); cboxVideo.setChecked(false); txtCboxDes.setVisibility(View.GONE); txtCboxVoice.setVisibility(View.GONE); txtCboxVideo.setVisibility(View.GONE); switch ( checkSign ){ case 1: cboxDes.setChecked(true); txtCboxDes.setVisibility(View.VISIBLE); break; case 2: cboxVideo.setChecked(true); txtCboxVideo.setVisibility(View.VISIBLE); break; case 3: cboxVoice.setChecked(true); txtCboxVoice.setVisibility(View.VISIBLE); break; } }
标签:GONE,false,自定义,单选框,setChecked,setVisibility,true,View From: https://www.cnblogs.com/remix777/p/17898901.html