重置适配器时出错

时间:2015-10-12 12:47:34

标签: android flipview

我在我的应用程序中使用了Aphid-FlipView库,我正在尝试重置适配器,但它给出错误并崩溃..

ArrayAdapter adp = (ArrayAdapter) flipView.getAdapter();
                if (adp != null) {
                    adp.clear();                    
                    adp.notifyDataSetChanged();

Logcat结果如下

10-12 18:02:39.939: E/AndroidRuntime(22161): FATAL EXCEPTION: main
10-12 18:02:39.939: E/AndroidRuntime(22161): Process: com.example.rssreader2, PID: 22161
10-12 18:02:39.939: E/AndroidRuntime(22161): junit.framework.AssertionFailedError: Invalid selection position
10-12 18:02:39.939: E/AndroidRuntime(22161):    at junit.framework.Assert.fail(Assert.java:50)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at junit.framework.Assert.assertTrue(Assert.java:20)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.aphidmobile.flip.FlipViewController.setSelection(FlipViewController.java:312)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.aphidmobile.flip.FlipViewController.onDataChanged(FlipViewController.java:606)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.aphidmobile.flip.FlipViewController.access$2(FlipViewController.java:596)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.aphidmobile.flip.FlipViewController$MyDataSetObserver.onChanged(FlipViewController.java:613)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.widget.ArrayAdapter.notifyDataSetChanged(ArrayAdapter.java:286)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.example.rssreader2.MainActivity.UpdateConnectedFlags(MainActivity.java:153)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.example.rssreader2.MainActivity.access$4(MainActivity.java:144)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.example.rssreader2.MainActivity$1.onRefresh(MainActivity.java:108)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.support.v4.widget.SwipeRefreshLayout$1.onAnimationEnd(SwipeRefreshLayout.java:182)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.support.v4.widget.CircleImageView.onAnimationEnd(CircleImageView.java:107)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewGroup.finishAnimatingView(ViewGroup.java:5269)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.draw(View.java:14397)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2947)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.draw(View.java:14475)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.getDisplayList(View.java:13369)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.getDisplayList(View.java:13411)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.draw(View.java:14189)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.getDisplayList(View.java:13364)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.getDisplayList(View.java:13411)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.draw(View.java:14189)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.draw(View.java:14475)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.android.internal.widget.ActionBarOverlayLayout.draw(ActionBarOverlayLayout.java:381)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.getDisplayList(View.java:13369)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.getDisplayList(View.java:13411)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.draw(View.java:14189)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.draw(View.java:14475)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.widget.FrameLayout.draw(FrameLayout.java:472)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2587)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.getDisplayList(View.java:13369)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.View.getDisplayList(View.java:13411)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2381)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2253)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1883)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.Choreographer.doCallbacks(Choreographer.java:574)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.Choreographer.doFrame(Choreographer.java:544)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.os.Handler.handleCallback(Handler.java:733)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.os.Handler.dispatchMessage(Handler.java:95)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.os.Looper.loop(Looper.java:136)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at android.app.ActivityThread.main(ActivityThread.java:5081)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at java.lang.reflect.Method.invokeNative(Native Method)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at java.lang.reflect.Method.invoke(Method.java:515)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:781)
10-12 18:02:39.939: E/AndroidRuntime(22161):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

如果我重置ListView,相同的代码工作正常。是代码有问题还是某些东西导致库中的错误。任何重置适配器的替代方法。感谢。

0 个答案:

没有答案