Honeycomb SDK 是否破坏了 GridView 的向后兼容性?
我正在构建一个与 1.6 及更高版本的设备兼容的平板电脑版本的应用程序,我发现崩溃肯定与 SDK 问题有关。我使用片段静态库来支持片段,但仍然向后兼容。
如果我使用 2.3 sdk 库进行编译,该应用程序可以在 2.2 设备和 Xoom 上正常运行。但是,如果使用 3.0 sdk 编译,该应用程序在 Xoom 上运行良好,但在 pre-honeycomb 设备上崩溃,出现以下异常:
java.lang.NoSuchMethodError: android.widget.AbsListView.setAdapter
我在代码中做了什么崩溃是在具有扩展 BaseAdapter 的类的 GridView 类上设置适配器。
还有其他人看到这个吗?
谢谢, 杰西
I'm working on building a tablet version of an app that will be compatible with 1.6 and up devices and I'm seeing a crash that must be related to an SDK problem. I'm using the fragment static library to be able to support fragments but still be backward compatible.
If I compile with 2.3 sdk libraries, the app works on both a 2.2 device and a Xoom just fine. However, if compiled with the 3.0 sdk, the app runs fine on the Xoom, but crashes on pre-honeycomb devices with this exception:
java.lang.NoSuchMethodError: android.widget.AbsListView.setAdapter
What I am doing in the code where it crashes is setting the adapter on a GridView class with a class that extends BaseAdapter.
Anyone else seeing this?
Thanks,
Jess
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定异常背后的原因,但解决方法是将视图转换为 AdapterView(在蜂窝和预蜂窝中定义方法的类)。
Not sure of the reasoning behind the exception, but the workaround is to cast your view as an AdapterView (the class that defines the method in both honeycomb and pre-honeycomb).
AbsListView.setAdapter 说它自 Api 级别 11 - Android 3.0 起可用,所以我并不惊讶您在 Honeycomb 之前的设备上收到此错误。
The docs for AbsListView.setAdapter says it is available since Api level 11 - Android 3.0, so I am not astonished you get this Error on pre Honeycomb devices.