I\'m trying to create an onCheckedChanged Listener for my RadioGroup, but eclipse is throwing erros at me. this is the code
<
Make sure you imported the correct package import android.widget.RadioGroup.OnCheckedChangeListener;
then the @Override
will be correct
I think you have imported the wrong package.
You should import
android.widget.RadioGroup.OnCheckedChangeListener
instead of
android.widget.CompoundButton.OnCheckedChangeListener
You can directly add the listener with the ClassName
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
}
});
If, for example, you already are using a CompoundButton and associated OnCheckedChangeListener, you will not be able to import the RadioGroup class, but will still be able to access it directly using this solution.