java. Lang.illegalargumentexception: the observer is null
•
Java
A user of one of my applications reported this error I'm confused about how to solve what it means After a Google search... Still no luck Anyone who has seen this before or knows how to solve 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)
It comes from this function in my pageradapter:
@Override public void destroyItem(View collection,int position,Object view) { ((ViewPager) collection).removeView((View) view); }
Solution
I have the same problem. It seems that unregisterdatasetobserver on your dealpageadapter is being called twice To solve this problem, I override unregisterdatasetobserver in my adapter
@Override public void unregisterDataSetObserver(DataSetObserver observer) { if (observer != null) { super.unregisterDataSetObserver(observer); } }
I hope this can help!
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码