Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
运行我的代码时,当我为我的视图初始化 XML 布局时,我得到一个 java.lang.ClassCastException: android.view.View。
为什么?
更新
问题是因为我在视图元素中添加了一个按钮。更正了这个位置,它再次工作
由于我们看到它不能转换为android.view.View我只能猜测它AppZappy.NIRailAndBus.UI.ToggleImageButton不会扩展 View 或 View 的子类,但我需要查看类声明来验证这一点。
android.view.View
AppZappy.NIRailAndBus.UI.ToggleImageButton
发现我的问题在别处。在视图元素中添加一个按钮,这似乎是导致异常的原因。
谢谢你的帮助