'Error inflating class com.andexert.expandablelayout.library.ExpandableLayout

Im getting this error

android.view.InflateException: Binary XML file line #12: Error inflating class com.andexert.expandablelayout.library.ExpandableLayout E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:633) E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:504) E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:414) E/AndroidRuntime: at cl.rpro.vendormobile.tm.controller.activity.ActivityTareas.onCreateView(ActivityTareas.java:56) while trying to implement an ExpandableLayout inside a Tab using FragmentTabs, I Used this sample and library https://github.com/astuetz/PagerSlidingTabStrip for the FragmentTabs and this one http://android-arsenal.com/details/1/969 for the ExpandableLayout.

Here is my layout.xml

<?xml version="1.0" encoding="utf-8"?>

android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:expandable="http://schemas.android.com/tools"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">

<com.andexert.expandablelayout.library.ExpandableLayout
    android:id="@+id/first"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    expandable:el_headerLayout="@layout/view_header"
    expandable:el_contentLayout="@layout/view_content"
    android:background="#ffff"/>

<com.andexert.expandablelayout.library.ExpandableLayoutListView
    android:id="@+id/listview"
    android:layout_below="@+id/first"
    android:layout_width="match_parent"
    android:layout_marginTop="15dp"
    android:layout_height="match_parent"/>

And my Activity.java

public class ActivityTareas extends Fragment {
private final String[] array = {"Hello", "World", "Android", "is", "Awesome", "World", "Android", "is", "Awesome", "World", "Android", "is", "Awesome", "World", "Android", "is", "Awesome"};


public static final String ARG_PAGE = "ARG_PAGE";

private int mPage;

public static ActivityTareas newInstance(int page) {
    Bundle args = new Bundle();
    args.putInt(ARG_PAGE, page);
    ActivityTareas fragment = new ActivityTareas();
    fragment.setArguments(args);
    return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPage = getArguments().getInt(ARG_PAGE);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.tm_activity_inicio_tareas, container, false); //The Exception points at this line
    super.onCreate(savedInstanceState);

    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this.getActivity(), R.layout.view_row, R.id.header_text, array);
    final ExpandableLayoutListView expandableLayoutListView = (ExpandableLayoutListView) view.findViewById(R.id.listview);

    expandableLayoutListView.setAdapter(arrayAdapter);
    return view;

}

}

Any suggestions?



Solution 1:[1]

you should add Kotlin plugins in build.gradle() , then can use this library .

classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version'

and this line :

apply plugin: 'org.jetbrains.kotlin.android'

Solution 2:[2]

Try change the code in your layout.xml from xmlns:expandable="http://schemas.android.com/tools" to xmlns:expandable="http://schemas.android.com/apk/res-auto"

Solution 3:[3]

Since there doesn't seem to be any answer for this, here is the way I fixed it.

To fix the exception, declare the namespace "app" with xmlns:app="http://schemas.android.com/apk/res-auto" and instead of using <fooNamespace>:el_headerLayout and <fooNamespace>:el_contentLayout, use respectively app:el_headerLayout and app:el_contentLayout to assign your layouts.

Cheers.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Amin Majlesi
Solution 2 Grace Coder
Solution 3