Using a custom view from xml. View class cast error
When running my code i get a java.lang.Cl开发者_运维知识库assCastException: android.view.View when I initialise the XML layout for my view.
Why?
UPDATE
Problem was since I was adding a button inside a view element. Corrected this placement and it worked again
Since we see that it can't cast to android.view.View
I can only guess that AppZappy.NIRailAndBus.UI.ToggleImageButton
does not extend View or a subclass of View but I would need to see the class declaration to verify that.
Found my problem was elsewhere. Was adding a button inside a view element which seemed to be cause the exception.
Thanks for your help
精彩评论