开发者

Using a custom view from xml. View class cast error

开发者 https://www.devze.com 2023-02-13 12:25 出处:网络
When running my code i get a java.lang.Cl开发者_运维知识库assCastException: android.view.View when I initialise the XML layout for my view.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消