Skip to content
Advertisement

android.support.v7.widget.AppCompatButton cannot be cast to android.widget.LinearLayout

I’m developing an app and I had some errors. When I run on the tablet it gives this error, but when I go to mobile it works perfectly. I already tried to clean and rebuild and tried to reboot the computer but I’m still having errors.

See the code below:

JavaScript

XML

JavaScript

And the others linearlayout is the same, the error that show me is

JavaScript

The strange thing is that the error only shows when I run in tablets, and on a regular phone it’s normal.

Advertisement

Answer

the strange is that the error only show when i run in tablets, in regular phone its normal

Do you have any additional layout- folders declared in /res? My guess would be that you have another layout file sharing the same name in a size-specific folder (e.g. in layout-xlarge) which has android:id="@+id/btCatalogo" assigned to an AppCompatButton rather than a LinearLayout.

See also – Supporting Multiple Screens

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement