2

尝试使用 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" />
4

1 回答 1

5

编译器已经说了

new View.OnFocusChangeListener() {
...
}

重点是View

于 2013-03-15T14:20:38.820 回答