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

Exception android.widget.ImageView cannot be cast to android.support.v7.widget.AppCompatImageView #53

Open
drottsgard opened this issue Oct 24, 2018 · 7 comments
Assignees
Labels

Comments

@drottsgard
Copy link

I've been trying to implement your Floating Action Button. I've followed the instructions you've made. When I try to run my app I get: Caused by: java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.support.v7.widget.AppCompatImageView

I'm not sure if it's something on my side, or on the main source code. The error is pointing at line 52 in your FabOptionsContainer.

Thanks in advance!

@JoaquimLey
Copy link
Owner

Hey @alexdrottsgard
Have you tried to clean your project and build again?

@JoaquimLey JoaquimLey self-assigned this Oct 24, 2018
@drottsgard
Copy link
Author

Yeah I have..

@JoaquimLey
Copy link
Owner

This shows a missing library if you read the error message carefully.
Also, I would need a little more context/code to understand what might be happening, which version are you importing from gradle?

@drottsgard
Copy link
Author

Yeah sorry! I have a Google Map Activity, on which I put your FAB. I've made the menu xml and I put it programmatically in my MapsActivity. My layout is a FrameLayout, which has the map fragment and the FAB.

How I make my menu item:

<item
        android:id="@+id/first_item"
        android:icon="@drawable/my_image"
        android:title="First Item" />

I have also tried to do:

<item
        android:id="@+id/first_item"
        app:srcCompat="@drawable/my_image"
        android:title="First Item" />

My onCreate, where I put the menu to the FAB:

fabOptions = findViewById(R.id.fab);
fabOptions.setButtonsMenu(R.menu.fab_menu);

Version in my gradle:

implementation 'com.github.joaquimley:faboptions:1.2.0'

@JoaquimLey
Copy link
Owner

Can you provide the list of your other dependencies?

@abduldblogger
Copy link

@alexdrottsgard I think issue is here:

<item
        android:id="@+id/first_item"
        app:srcCompat="@drawable/my_image"
        android:title="First Item" />

you are using srcCompat and this is causing the issue in Casting from normal image to srcCompat image

@JoaquimLey
Copy link
Owner

Oh I haven't tested with srcCompat in the menu, I'm not sure if it works tbh.
But can't you use the same as the sample?

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

No branches or pull requests

3 participants