1

我最近得到了一台 Xoom,我目前正在努力改进我的 HoneyComb 平板电脑应用程序。一切都很好,我的最后一个问题涉及一个带有 FastScroll 的 ListView 到 TabActavity。

this.setListAdapter(mIndexAdapter);
ListView lv = getListView();
lv.setTextFilterEnabled(true);
//lv.setFastScrollEnabled(true);

自 2 年以来,此代码在所有手机上都运行良好,但我现在遇到了 setFastScrollEnabled 问题!正如您在我的代码片段中看到的那样,我必须删除此行,否则会出现此异常(见下文)

任何想法是什么问题?我发现的唯一解决方法是:

    if(android.os.Build.VERSION.SDK_INT<11)
        lv.setFastScrollEnabled(true);

我可以发布我的适配器,但我真的不认为这是相关的。

06-13 13:24:50.520: INFO/ActivityManager(151): Starting: Intent { cmp=tof.cv.mpp/tof.cv.ui.BETrainsTabActivity } from pid 2327
06-13 13:24:50.620: DEBUG/dalvikvm(2327): GC_CONCURRENT freed 203K, 5% free 7383K/7751K, paused 2ms+3ms
06-13 13:24:50.700: DEBUG/AndroidRuntime(2327): Shutting down VM
06-13 13:24:50.700: WARN/dalvikvm(2327): threadid=1: thread exiting with uncaught exception (group=0x40110760)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327): FATAL EXCEPTION: main
06-13 13:24:50.700: ERROR/AndroidRuntime(2327): java.lang.NullPointerException
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.FastScroller.getThumbPositionForListPosition(FastScroller.java:612)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.FastScroller.onScroll(FastScroller.java:421)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1252)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.ListView.layoutChildren(ListView.java:1689)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.AbsListView.onLayout(AbsListView.java:1800)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1542)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1403)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1314)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.FrameLayout.onLayout(FrameLayout.java:400)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1542)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1403)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1314)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.FrameLayout.onLayout(FrameLayout.java:400)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.FrameLayout.onLayout(FrameLayout.java:400)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1542)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1403)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1314)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.FrameLayout.onLayout(FrameLayout.java:400)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.FrameLayout.onLayout(FrameLayout.java:400)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1542)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1403)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1314)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.widget.FrameLayout.onLayout(FrameLayout.java:400)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.View.layout(View.java:9581)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewGroup.layout(ViewGroup.java:3877)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1253)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.view.ViewRoot.handleMessage(ViewRoot.java:2003)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.os.Looper.loop(Looper.java:132)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at android.app.ActivityThread.main(ActivityThread.java:4025)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at java.lang.reflect.Method.invokeNative(Native Method)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at java.lang.reflect.Method.invoke(Method.java:491)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
06-13 13:24:50.700: ERROR/AndroidRuntime(2327):     at dalvik.system.NativeStart.main(Native Method)
06-13 13:24:50.710: WARN/ActivityManager(151):   Force finishing activity tof.cv.mpp/tof.cv.ui.BETrainsTabActivity
4

2 回答 2

2

如果我从 getSections() 方法返回 null,我会看到这一点。将其更改为返回空数组即可(新字符串 [0])。但是,在这种情况下,快速滚动并不像在手机上那样工作。

于 2011-07-20T18:57:43.443 回答
1

我已经看到在 Android 3.1 和 3.0.1 上多次报告该错误(在 FastScroller.java:609 上)以前使用 Fast Scroller 的东西已经不复存在了。

于 2011-06-26T07:07:18.160 回答