fragment1.xml
<RelativeLayout 
	xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:paddingBottom="0dp"
    android:paddingLeft="30dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp" >
        
    <ExpandableListView
       	android:id="@+id/expListView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:paddingLeft="5dp"
        android:paddingTop="5dp"
        android:background="#003060"
   		android:layout_width="match_parent"
   		android:layout_height="wrap_content"
   		android:clickable="true"
   		android:dividerHeight="3dp" />
</RelativeLayout>
Lors de l'utilisation de ExpandableListView, si l'héritage de la classe qui implémente le fragment est ** ListFragment **,
fragment1.java
public class Fragment1  extends ListFragment {
** onViewCreated ** lève une ** RuntimeException **. (Pour être exact, une exception est levée dans la superclasse, c'est-à-dire onViewCreated de ListFragment)
 "Content has view with id attribute 'android.R.id.list' that is not a ListView class"
Pour éviter cela, créez l'héritage ** Fragment ** au lieu de ListFragment.
fragment1.java
public class Fragment1  extends Fragment {
        Recommended Posts