错误:(12)找不到属性' el_headerLayout'在包中

时间:2016-06-20 21:09:51

标签: java android xml android-layout

我将创建可扩展的布局内容,因此我使用此https://github.com/traex/ExpandableLayout  我收到的错误是没有找到资源标识符:

>         Error:(12) No resource identifier found for attribute 'el_headerLayout' in package 'com.example.android.collapsedcontentapp'
>     Error:(12) No resource identifier found for attribute 'el_contentLayout' in package
> 'com.example.android.collapsedcontentapp'
>     Error:(9) No resource identifier found for attribute 'el_headerLayout' in package 'com.example.android.collapsedcontentapp'
>     Error:(9) No resource identifier found for attribute 'el_contentLayout' in package
> 'com.example.android.collapsedcontentapp'

它无法在我的布局文件夹中找到我的view_header和view_content xml文件 这是我的xml代码:

活动main.xml:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:expandable="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        tools:context=".MainActivity">

        <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="#e74c3c"/>

        <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"/>
    </RelativeLayout>

查看content.xml:

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <EditText
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:gravity="center"
        android:hint="Hello World !"
        android:textColor="@android:color/white"
        android:background="#c0392b"/>

    <Button
        android:layout_below="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="click ME !"/>

</RelativeLayout>

view_header.xml:

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/header_text"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:padding="10dp"
        android:textColor="@android:color/white"
        android:text="ExpandableLayout Header!"
        android:gravity="center"/>

</RelativeLayout>

view_row.xml:

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:expandable="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


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

</RelativeLayout>

1 个答案:

答案 0 :(得分:1)

尝试更换:

answers_count

使用:

xmlns:expandable="http://schemas.android.com/apk/res-auto"

这当然是假设包含自定义视图的库已添加到xmlns:expandable="http://schemas.android.com/apk/com.andexert.expandablelayout.library"

中的项目中