我在Android上遇到了ClassCastException的奇怪问题.一个类不能被转换为同一个类:
java.lang.RuntimeException: Unable to start activity ComponentInfo: java.lang.ClassCastException: com.example.model.BadeWrapper cannot be cast to com.example.model.BadgeWrapper
java.lang.ClassCastException: com.example.events.widgets.TouchyWebView cannot be cast to com.example.events.widgets.TouchyWebView
java.lang.ClassCastException: com.example.friends.widgets.FriendsTabView cannot be cast to com.example.friends.widgets.FriendsTabView
Run Code Online (Sandbox Code Playgroud)
当我找到有错误的行时,它所做的就是通过id查找视图或使用参数创建片段,例如:
FriendsTabView friendsTabView;
friendsTabView = (FriendsTabView) view.findViewById(R.id.friends_bottom_tab_panel);
Run Code Online (Sandbox Code Playgroud)
正如我的BugSense所说,这个问题只发生在带有android 5.0.0(三星SM-G900F)的三星Galaxy S5上.我在其他设备上从未遇到过这个问题:
有没有人遇到过这个问题?有没有办法解决它?