单选框RadioGroup 修改获取选中值
RadioGroup radioGroup = (RadioGroup) contentView.findViewById(R.id.popup_modify_role_user_role);
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
// 以下代码,表示只执行人为点击,不执行默认系统的
View checkView = mView.findViewById(i);
if (!checkView.isPressed()){
return;
}
// 获取到的id是单选框成员的id, 成员一定要设置id,否则反复点击,会导致id增大
log.d("======", "选中的id为" + radioGroup.getCheckedRadioButtonId());
}
});
Switch 控件
Switch modelSwitch = mView.findViewById(R.id.frag_switch_device_model);
modelSwitch.setOnCheckedChangeListener((CompoundButton compoundButton, boolean b) -> {
if (!compoundButton.isPressed()) {
return;
}
mPresenter.changeNightMode(b);
});
版权声明:本文为my_web_advanced原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。