异常:cannot be cast to android.widget.HeaderViewListAdapter
原因:在4.4以前(API19)的系统中,要求必须在setAdapter(adapter)之前调用addFooterView(footer),否则就会引发该异常。在4.4以后就没有这样的要求了。
addFooterView() 在API level 15说明:
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that will also account for header and footer views.
现在:
Note: When first introduced, this method could only be called before setting the adapter with {@link #setAdapter(ListAdapter)}. Starting with {@link android.os.Build.VERSION_CODES#KITKAT}, this method may be called at any time. If the ListView's adapter does not extend {@link HeaderViewListAdapter}, it will be wrapped with a supporting instance of {@link WrapperListAdapter}.