For the code of the header and footer use:
mListHeader = inflater.inflate(R.layout.header, null);
mListFooter = inflater.inflate(R.layout.footer, null);
If you use your current code the inflated views mListHeader
and mListFooter
will have as LayoutParams
an instance of FrameLayout.LayoutParams
(you pass the container
as the second parameter which basically suggest the type of the parent that the inflated views will have). However when you call setListAdapter()
the ListView
does some work under the hood where it will iterate over the views above and access their LayoutParams
(which the ListView
expects to be an instance of AbsListView.LayoutParams
) resulting in the ClassCastException
.