Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoCompleteTextView does not work with @OnItemClick #102

Open
jeffdcamp opened this issue Feb 14, 2014 · 7 comments
Open

AutoCompleteTextView does not work with @OnItemClick #102

jeffdcamp opened this issue Feb 14, 2014 · 7 comments

Comments

@jeffdcamp
Copy link

  • For the code:
    @InjectView(R.id.item)
    AutoCompleteTextView autoCompleteTextView;
    ...

    @OnItemClick(R.id.item)
    public void onMyItemClick(long id) {
    ...
    }

  • During runtime the following exception will be thrown:
    java.lang.ClassCastException: android.widget.AutoCompleteTextView cannot be cast to android.widget.AdapterView

  • Cause (from ...$$ViewInjector.java):
    target.autoCompleteTextView = (android.widget.AutoCompleteTextView) view;
    ((android.widget.AdapterView) view).setOnItemClickListener( // <-- !!! ERROR !!!
    new android.widget.AdapterView.OnItemClickListener() {
    @OverRide public void onItemClick(
    android.widget.AdapterView<?> p0,
    android.view.View p1,
    int p2,
    long p3
    ) {
    target.onMyItemClick(p3);
    }
    });

  • Error Reason:
    AutoCompleteTextView does not extend/implement AdapterView

  • Notes
    AutoCompleteTextView DOES have a setOnItemClickListener(android.widget.AdapterView.OnItemClickListener ) method, just like ListView. I don't know what other widgets may run into this same issue.

@vbevans94
Copy link

@OnItemClick is for AdapterViews and AutoCompleteTextView is not a child of it. It has an instance of the AdapterView to display the contents of suggestions, but you have no access to that member, so you should use common way for adding an item click listener.

@manijshrestha
Copy link

I have added a new Annotation (@OnAutoCompleteItemClick) and submitted a pull request #242

@sandrocsimas
Copy link

This feature will be nice!

@valllllll2000
Copy link

Hi, I am also having this issue, any ideas when this will be merged? Thanks

@manijshrestha
Copy link

Not sure if and when this will be merged.

@chubecode
Copy link

me too! How to fix this ?

@javichaques
Copy link

I have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants