Adapter class cast exception when removing a Footer view?

前端 未结 4 1761
不思量自难忘°
不思量自难忘° 2021-01-02 13:51

I have an exception I never thought I would see. A class cast exception of the adapter when removing a footer view from a ListView (sic).

 java.lang.ClassCa         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 13:57

    Add your footer view to ListView before calling setAdapter() method.

    Added:

    public void addFooterView (View v)
    

    Since: API Level 1 Add a fixed view to appear at the bottom of the list. If addFooterView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.

    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.

    Parameters v The view to add.

    Source

    Also you can check this interesting post.

    Hope this helps.

提交回复
热议问题