gpt4 book ai didi

android - ClassCastException : XAdapter cannot be cast to android. widget.BaseAdapter - FastScroller

转载 作者:太空狗 更新时间:2023-10-29 16:02:37 24 4
gpt4 key购买 nike

我创建了自己的适配器 - 实现 ListAdapter。我在 XML 中检查了 fastScrollEnabled:android:fastScrollEnabled="true"

但是,当绘制列表/网格时,我得到了一个 ClassCastException:

09-29 17:23:27.333: E/AndroidRuntime(25515): FATAL EXCEPTION: main
09-29 17:23:27.333: E/AndroidRuntime(25515): java.lang.ClassCastException: XAdapter cannot be cast to android.widget.BaseAdapter
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.FastScroller.getSectionsFromIndexer(FastScroller.java:541)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.FastScroller.getThumbPositionForListPosition(FastScroller.java:662)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.FastScroller.onScroll(FastScroller.java:487)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1337)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.GridView.layoutChildren(GridView.java:1301)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.AbsListView.onLayout(AbsListView.java:2012)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.View.layout(View.java:14289)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.View.layout(View.java:14289)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.View.layout(View.java:14289)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.View.layout(View.java:14289)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-29 17:23:27.333: E/AndroidRuntime(25515): at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:349)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.View.layout(View.java:14289)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-29 17:23:27.333: E/AndroidRuntime(25515): at com.slidingmenu.lib.CustomViewAbove.onLayout(CustomViewAbove.java:470)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.View.layout(View.java:14289)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.View.layout(View.java:14289)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.View.layout(View.java:14289)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1976)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1730)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.Choreographer.doFrame(Choreographer.java:532)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.os.Handler.handleCallback(Handler.java:730)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.os.Handler.dispatchMessage(Handler.java:92)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.os.Looper.loop(Looper.java:137)
09-29 17:23:27.333: E/AndroidRuntime(25515): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-29 17:23:27.333: E/AndroidRuntime(25515): at java.lang.reflect.Method.invokeNative(Native Method)
09-29 17:23:27.333: E/AndroidRuntime(25515): at java.lang.reflect.Method.invoke(Method.java:525)
09-29 17:23:27.333: E/AndroidRuntime(25515): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-29 17:23:27.333: E/AndroidRuntime(25515): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-29 17:23:27.333: E/AndroidRuntime(25515): at dalvik.system.NativeStart.main(Native Method)

最佳答案

好吧,如果您希望启用快速滚动,Android 的内置代码似乎假定您正在使用 BaseAdapter。

找不到关于该主题的信息,所以考虑将此信息发布到 SO 上。

解决方案是扩展 BaseAdapter。我不想这样做,因为我有自己的监听/刷新机制,但我无法找到不同的解决方案而不用太过摇摆不定。

进一步研究 FastScroller ,我不明白为什么它这么多基于 BaseAdapter 而不是 ListAdapter 或只是 Adapter。

关于android - ClassCastException : XAdapter cannot be cast to android. widget.BaseAdapter - FastScroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26118856/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com