首页 > 代码库 > android退出一个含有listview的activity时报java.lang.IllegalA

android退出一个含有listview的activity时报java.lang.IllegalA

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

原因是:

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

看不懂没关系,总之是adapter的错。查看代码发现当请求到的listview的数据list为空时,依然设置了adapter,而且代码又被try catch包裹,所以没有报错。解决方法就是在设置adapter之前,判断提供数据的list是否为null,且其元素是否为0.


android退出一个含有listview的activity时报java.lang.IllegalA