我得到这个错误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在选项卡中实现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;
}
}
有什么建议吗?
3条答案
按热度按时间avkwfej41#
您应该在build.gradle()中添加Kotlin插件,然后才能使用此库。
和此行:
n3schb8v2#
尝试将layout.xml中的代码从
xmlns:expandable="http://schemas.android.com/tools"
更改为xmlns:expandable="http://schemas.android.com/apk/res-auto"
wh6knrhe3#
因为似乎没有任何答案,这是我解决它的方法。
若要修复此异常,请使用
xmlns:app="http://schemas.android.com/apk/res-auto"
声明名称空间“app”,并分别使用app:el_headerLayout
和app:el_contentLayout
来分配布局,而不是使用<fooNamespace>:el_headerLayout
和<fooNamespace>:el_contentLayout
。干杯干杯干杯