Cannot add header view to list — setAdapter has already been called

后端 未结 10 2064
夕颜
夕颜 2020-12-03 13:38

I have one edittext field and one \"search\" button. When I click on search, I have to display a list view with data corresponding to the values entered in the edittext. I h

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 14:17

    The exception is thrown by android api.For API Level below KITKAT the addHeader() or the addFooter() method must be called before setAdapter() method.

    It is mentioned in the api documentation:

    Note: When first introduced, this method could only be called before setting the adapter with setAdapter(ListAdapter). Starting with Build.VERSION_CODES.KITKAT, this method may be called at any time. If the ListView's adapter does not extend HeaderViewListAdapter, it will be wrapped with a supporting instance of WrapperListAdapter.

提交回复
热议问题