问题描述
我的应用程序之一的用户报告这个错误。我很困惑,这是什么意思了如何解决它。经过一番google搜索......仍然没有运气的。之前,任何人都看到了这一点或不知道如何解决它?
java.lang.IllegalArgumentException:如果观察者为空。
在android.database.Observable.unregisterObserver(Observable.java:59)
在android.widget.BaseAdapter.unregisterDataSetObserver(BaseAdapter.java:42)
在android.widget.HeaderViewListAdapter.unregisterDataSetObserver(HeaderViewListAdapter.java:256)
在android.widget.AbsListView.onDetachedFromWindow(AbsListView.java:2309)
在android.view.View.dispatchDetachedFromWindow(View.java:8197)
在android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1968)
在android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1966)
在android.view.ViewGroup.removeViewInternal(ViewGroup.java:3257)
在android.view.ViewGroup.removeViewInternal(ViewGroup.java:3237)
在android.view.ViewGroup.removeView(ViewGroup.java:3185)
在com.aheudev.a.slickdeals.adapters.DealPageAdapter.destroyItem(DealPageAdapter.java:174)
在android.support.v4.view.ViewPager.populate(ViewPager.java:415)
在android.support.v4.view.ViewPager.completeScroll(ViewPager.java:696)
在android.support.v4.view.ViewPager.computeScroll(ViewPager.java:668)
在android.view.ViewGroup.drawChild(ViewGroup.java:2434)
在android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189)
在android.view.View.draw(View.java:9282)
在android.view.ViewGroup.drawChild(ViewGroup.java:2584)
在android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189)
在android.view.ViewGroup.drawChild(ViewGroup.java:2582)
在android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189)
在android.view.ViewGroup.drawChild(ViewGroup.java:2582)
在android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189)
在android.view.View.draw(View.java:9282)
在android.widget.FrameLayout.draw(FrameLayout.java:419)
在com.android.internal.policy.impl.PhoneWindow $ DecorView.draw(PhoneWindow.java:1923)
在android.view.ViewRoot.draw(ViewRoot.java:1695)
在android.view.ViewRoot.performTraversals(ViewRoot.java:1410)
在android.view.ViewRoot.handleMessage(ViewRoot.java:2040)
在android.os.Handler.dispatchMessage(Handler.java:99)
在android.os.Looper.loop(Looper.java:132)
在android.app.ActivityThread.main(ActivityThread.java:4123)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:491)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:841)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
在dalvik.system.NativeStart.main(本机方法)
和它的这个功能在我PagerAdapter来了:
@覆盖
公共无效destroyItem(查看收集,INT位置,对象视图){
((ViewPager)集合).removeView((视图));
}
我也有同样的问题,它似乎正在被调用两次unregisterDataSetObserver您DealPageAdapter。要解决我覆盖了unregisterDataSetObserver在我的适配器这样的问题
@覆盖
公共无效unregisterDataSetObserver(DataSetObserver观察者){
如果(观察者!= NULL){
super.unregisterDataSetObserver(观察员);
}
}
希望这有助于!
A user of one of my apps reported this error. I'm confused as to what it means an how to fix it. After a bit of googling...still no luck. Anyone seen this before or know how to fix it?
java.lang.IllegalArgumentException: The observer is null.
at android.database.Observable.unregisterObserver(Observable.java:59)
at android.widget.BaseAdapter.unregisterDataSetObserver(BaseAdapter.java:42)
at android.widget.HeaderViewListAdapter.unregisterDataSetObserver(HeaderViewListAdapter.java:256)
at android.widget.AbsListView.onDetachedFromWindow(AbsListView.java:2309)
at android.view.View.dispatchDetachedFromWindow(View.java:8197)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1968)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1966)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3257)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:3237)
at android.view.ViewGroup.removeView(ViewGroup.java:3185)
at com.aheudev.a.slickdeals.adapters.DealPageAdapter.destroyItem(DealPageAdapter.java:174)
at android.support.v4.view.ViewPager.populate(ViewPager.java:415)
at android.support.v4.view.ViewPager.completeScroll(ViewPager.java:696)
at android.support.v4.view.ViewPager.computeScroll(ViewPager.java:668)
at android.view.ViewGroup.drawChild(ViewGroup.java:2434)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189)
at android.view.View.draw(View.java:9282)
at android.view.ViewGroup.drawChild(ViewGroup.java:2584)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189)
at android.view.ViewGroup.drawChild(ViewGroup.java:2582)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189)
at android.view.ViewGroup.drawChild(ViewGroup.java:2582)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189)
at android.view.View.draw(View.java:9282)
at android.widget.FrameLayout.draw(FrameLayout.java:419)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1923)
at android.view.ViewRoot.draw(ViewRoot.java:1695)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1410)
at android.view.ViewRoot.handleMessage(ViewRoot.java:2040)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
And it came from this function in my PagerAdapter:
@Override
public void destroyItem(View collection, int position, Object view) {
((ViewPager) collection).removeView((View) view);
}
I too was having the same problem and it seems that unregisterDataSetObserver on your DealPageAdapter is being called twice. To fix the problem I overwrote the unregisterDataSetObserver in my Adapter as such
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
if (observer != null) {
super.unregisterDataSetObserver(observer);
}
}
Hope this helps!
这篇关于java.lang.IllegalArgumentException:如果观察者为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!