当RadioGroup与CompoundButton同时存在且都要监听事件时CompoundButton.OnCheckedChangeListener与RadioGroup.OnCheckedChangeListener就会出现冲突,导入任何一个包import android.widget.RadioGroup.OnCheckedChangeListener;会出现如下错误:
The method setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener)in the type RadioGroupisnot applicable for the arguments (newCompoundButton.OnCheckedChangeListener(){})
或import android.widget.RadioGroup.OnCheckedChangeListener collides with another import statement
又不能同时导入,因此又要使用两者,网上给出个方法:
不要导入任何事件,在事件中加入具体名,红色部分:
howHotRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()...
friendlyCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()...