Estoy intentando añadir una cabecera a un ExpandableListView así:Android: ClassCastException al agregar una vista de encabezado a ExpandableListView
headerView = View.inflate(this, R.layout.header, null);
expandableListView.addHeaderView(headerView);
expandableListView.setAdapter(new SectionedAdapter(this));
Lo que me da el siguiente 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)
Este es sucediendo en la llamada al expandableListView.setAdapter(new SectionedAdapter(this))
, pero no puedo entender por qué. ¿Algunas ideas?
Pasé las últimas dos horas tratando de resolver esto. ¡Gracias! – Tenfour04
Gracias por publicar la respuesta aquí, ¡muy útil! – AndersG
¡Qué mensaje de error tan tonto ... Gracias por ahorrar tiempo! – SuitUp