faboptions
faboptions copied to clipboard
Exception android.widget.ImageView cannot be cast to android.support.v7.widget.AppCompatImageView
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!
Hey @alexdrottsgard Have you tried to clean your project and build again?
Yeah I have..
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?
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'
Can you provide the list of your other dependencies?
@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
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?
- https://github.com/JoaquimLey/faboptions/blob/development/sample/src/main/res/menu/menu_faboptions.xml