Skip to main content

Posts

Showing posts with the label linearlayout

Android: ClassCastException when adding a header view to ExpandableListView

I'm trying to add a header to an ExpandableListView like so: headerView = View.inflate(this, R.layout.header, null); expandableListView.addHeaderView(headerView); expandableListView.setAdapter(new SectionedAdapter(this)); Which gives me the following error: 12-08 16:23:42.354: ERROR/AndroidRuntime(421): Caused by: java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams 12-08 16:23:42.354: ERROR/AndroidRuntime(421): at android.widget.ListView.clearRecycledState(ListView.java:504) 12-08 16:23:42.354: ERROR/AndroidRuntime(421): at android.widget.ListView.resetList(ListView.java:490) 12-08 16:23:42.354: ERROR/AndroidRuntime(421): at android.widget.ListView.setAdapter(ListView.java:422) 12-08 16:23:42.354: ERROR/AndroidRuntime(421): at android.widget.ExpandableListView.setAdapter(ExpandableListView.java:475) This is happening at the call to expandableListView.setAdapter(new SectionedAdapter(this)) , but I can't figure out why. Any ideas? Source: Tips4al