10BC0 @OptionsItem for android.R.id.home causes lint error · Issue #1981 · androidannotations/androidannotations · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

@OptionsItem for android.R.id.home causes lint error #1981

@ened

Description

@ened

AndroidAnnotations version:

4.2.0

Android compile SDK version:

Support libs: 25.3.0

Annotated code:

    @OptionsItem(android.R.id.home)
    void homeClicked() {
        finish();
    }

Expected generated code:

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int itemId_ = item.getItemId();
        if (itemId_ == android.R.id.home) {
            homeClicked();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

Actual generated code:

    import android.R;

    ...

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int itemId_ = item.getItemId();
        if (itemId_ == R.id.home) {
            homeClicked();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

lint warning:

Don't include android.R here; use a fully qualified name for each usage instead

Seems to be new in Android Tools 23.3.

(or maybe I shouldn't listen for that button at all! 😄)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0