android - 旋转木马android错误: No resource identifier found for attribute 'UseReflection' in package

标签 android xml android-layout carousel

实现轮播时,我的 xml 文件出现问题。 main.xml 布局显示以下错误

在此行发现多个注释:

- error: No resource identifier found for attribute 'UseReflection' in package 
 ''
- error: No resource identifier found for attribute 'SelectedItem' in package 
 ''
- error: No resource identifier found for attribute 'Items' in package ''

- error: No resource identifier found for attribute 'Names' in package 
 ''

主要布局如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:pj="http://schemas.android.com/apk/res/packagename"

    xmlns:bm="package name"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="vertical"
>

     <TextView

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:layout_weight="0.5"

        android:text="text"

        android:id="@+id/selected_item"

        android:background="#1E1921"

        android:textColor="#A85E4F"

        android:textStyle="normal"

        />

   <package.controls.Carousel 

         android:id="@+id/carousel"

         android:layout_width="413dp"

         android:layout_height="446dp"

         android:layout_gravity="center_horizontal"

         pj:Items="@array/entries"

         pj:Names="@array/names"

         pj:SelectedItem="0"

         pj:UseReflection="true" >

     </package.controls.Carousel>

</LinearLayout>

我的值文件夹中的 attrs.xml

<resources>

        <declare-styleable name="Carousel">

        <attr name="android:gravity" /> 

        <attr name="android:animationDuration" />

        <attr name="UseReflection" format="boolean"/>

        <attr name="Items" format="integer"/>

        <attr name="SelectedItem" format="integer"/>

        <attr name="maxTheta" format="float"/>

        <attr name="minQuantity" format="integer"/>

        <attr name="maxQuantity" format="integer"/>

        <attr name="Names" format="string" />

    </declare-styleable>    

</resources>

这是 eclipse 错误还是我错过了一步。可以帮忙吗?

最佳答案

您是否将 packagename 正确替换为实际应用程序的包名称(如 com.myapp)?

xmlns:pj="http://schemas.android.com/apk/res/packagename"

应该是

xmlns:pj="http://schemas.android.com/apk/res/com.myapp"

此外,根据 android 约定,您的属性名称应以小写字母开头。

关于android - 旋转木马android错误: No resource identifier found for attribute 'UseReflection' in package,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13422110/

相关文章:

android - Admob 梯度依赖

android - 构建 Android Studio 项目时如何添加 Stacktrace 或调试选项

java - 如何将xml文件写入AWS

Android - 在 LinearLayout 或 RelativeLayout 中为 View 的 topMargin/bottomMargin/等设置动画

android - Ionic 3 应用程序按预期从 FCM 网络界面接收后台通知,但没有使用 curl

android - 需要使用 appium 识别 android 元素的 xpath

c# - 如何使用 XMLDocument 类从 C# 中的 XML 文件获取数据?

c# - WP7 - 解析 XML 数据

java - relativelayout 在另外两个 View 之间插入一个 View

android - 一旦收到元素,微调器就会向下移动