editText setOnFocusChangeListener出错

时间:2013-03-15 14:16:57

标签: java android

尝试使用

的setOnFocusChangeListener
mMessageBox.setOnFocusChangeListener(new OnFocusChangeListener() {

    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        // TODO Auto-generated method stub

    }
});

但是当我在onCreate函数中使用此函数时,eclipse会出现错误

Multiple markers at this line
    - The method setOnFocusChangeListener(View.OnFocusChangeListener) in the type View is not applicable for the arguments (new 
     OnFocusChangeListener(){})
    - OnFocusChangeListener cannot be resolved to a type

是否因为我在清单文件中使用的最小sdk?我在清单文件中的sdk选项是

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="17" />

1 个答案:

答案 0 :(得分:5)

编译器已经说过了

new View.OnFocusChangeListener() {
...
}

重点在于View