What is triggering this Exception instance: “java.lang.IllegalArgumentException: The observer is null.” and how could it be avoid?

前端 未结 2 1126
感动是毒
感动是毒 2020-12-28 22:25

I\'m getting this exception when returning to the original ListActivity after opening an new activity with the content of the item selected by the user. It only

2条回答
  •  再見小時候
    2020-12-28 22:58

    I made the silly mistake of thinking that none of my classes were mentioned in the trace, but LoadingDataView is one of them. It doesn't show in the original trace but another that was related.

    Inside that class there is an anonymous ArrayAdapter that was where the incident is happening so I added this as a work around:

    @Override
    public void unregisterDataSetObserver(DataSetObserver observer) {
        if (observer != null) {
            super.unregisterDataSetObserver(observer);
        }
    }
    

    And it seems to work now although I'm still not sure why this method was called twice.

    Although, for now on I'm going to use Fragments as much as I can ;)

提交回复
热议问题