Can't implement OnCheckedChangeListener? [duplicate]

隐身守侯 提交于 2019-12-23 03:37:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!