java.lang.IllegalArgumentException: The observer is null

后端 未结 3 1165
慢半拍i
慢半拍i 2021-02-06 00:48

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

相关标签:
3条回答
  • 2021-02-06 01:23

    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!

    0 讨论(0)
  • 2021-02-06 01:24

    An alternative solution is to wrap the ListView and catch the exception. This solution worked for me, and I have yet not found any side effects.

        public class CustumListView extends ListView {

      public CustumListView(Context context, AttributeSet attrs) {
        super(context, attrs);
      }
    
      @Override
      protected void onDetachedFromWindow() {
        try {
          super.onDetachedFromWindow();
        } catch(IllegalArgumentException iae) {
    
        }
      }
    }
    

    0 讨论(0)
  • 2021-02-06 01:26

    There are a few people who have had your problem Here and Here

    From looking at the call stack it looks like your "view" registered a observer that it's now trying to unregister. That observer is no longer there even though it's expected. Hence the error. This might be a bug or it might be related to how you're doing things.

    Trying looking through the Android Source to see if you can track it down.

    Good luck.

    0 讨论(0)
提交回复
热议问题