问题
I've a question.
Here is my code:
public class MyCheckBox extends CheckBox implements OnCheckedChangeListener {
public MyCheckBox(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
But "onCheckedChangeListener" can't be implemented ( eclipse marks as red squiggly line). It says "Import onCheckedChangeListener", I'm clicking but nothing happens.
Is this eclipse bug or something else?
回答1:
OnCheckedChangeListener is for radio group.
So you need to implement android.widget.CompoundButton.OnCheckedChangeListener for CheckBox
回答2:
You need to make sure you have imported:
import android.widget.CompoundButton.OnCheckedChangeListener;
Problem could be here. Also tap CTRL+SHIFT+O that will clean your imports and add missing imports as well.
If it won't work, restart Eclipse and clean your project. If it still doesn't work, reinstall Eclipse completely.
来源:https://stackoverflow.com/questions/19841880/cant-implement-oncheckedchangelistener