扩展类com.andexert.expandablelayout.library.ExpandableLayout时出错

时间:2016-01-19 00:24:24

标签: android android-layout android-fragments android-studio

我收到此错误

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) 在尝试使用FragmentTabs在Tab中实现ExpandableLayout时,我使用此示例和库https://github.com/astuetz/PagerSlidingTabStrip作为FragmentTabs,将此http://android-arsenal.com/details/1/969用于ExpandableLayout。

这是我的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"/>

还有我的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;

}

}

有什么建议吗?

2 个答案:

答案 0 :(得分:0)

尝试将layout.xml中的代码从xmlns:expandable="http://schemas.android.com/tools"更改为xmlns:expandable="http://schemas.android.com/apk/res-auto"

答案 1 :(得分:0)

由于似乎没有任何答案,这是我修复它的方式。

要修复该异常,请使用xmlns:app="http://schemas.android.com/apk/res-auto"声明名称空间“app”,而不是使用<fooNamespace>:el_headerLayout<fooNamespace>:el_contentLayout,分别使用app:el_headerLayoutapp:el_contentLayout分配你的布局。

干杯。

相关问题