我最近得到了一个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
答案 0 :(得分:2)
如果我从getSections()方法返回null,我会看到这一点。更改它以返回一个空数组而不是工作(new String [0])。但是,快速滚动在这种情况下不像在手机上那样有效。
答案 1 :(得分:1)
我在Android 3.1和3.0.1上看到多次报告错误(在FastScroller.java:609) 之前使用Fast Scroller的工作已经不复存在了。