Java 选择器:"&书信电报;项目>;标签需要一个';可抽出式&x27;属性";

Java 选择器:"&书信电报;项目>;标签需要一个';可抽出式&x27;属性";,java,android,xml,eclipse,Java,Android,Xml,Eclipse,我有以下按钮: <Button android:id="@+id/searchCompaniesButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableLeft="@drawable/company_icon" an

我有以下按钮:

<Button
            android:id="@+id/searchCompaniesButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"          
            android:drawableLeft="@drawable/company_icon"
            android:drawablePadding="10dp"
            android:drawableRight="@drawable/next_icon_big"
            android:gravity="left|center_vertical"
            android:paddingLeft="10dp"
            android:backgroud="@drawable/transparent_button_selector"
            android:paddingRight="10dp"
            android:text="@string/searchCompanies" />
我还有一个
colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
 <color name="lightGrey">#3d3d3d</color>
  <color name="veryLightGrey">#4d4d4d</color>
</resources>

#三维
#4D
但当我运行应用程序时,日志会显示:

“item”标记需要“drawable”属性

怎么回事?我知道类似的问题很少,但答案没有帮助。我试过:

  • 重新启动Eclipse
  • 清洁工程
  • 在真实设备上运行应用程序(粉碎)
替换此:

 <item android:drawable="@null" />

与:



并在颜色文件中添加透明颜色,代码为:#00000000

可绘制属性始终采用@drawable 你必须更换

<item android:drawable="@color/..."
      android:state_pressed="true" />


用这个,

<item
    android:state_pressed="true"
    android:drawable="@drawable/selected_state" />

然后在drawable文件夹中创建一个名为“selected_state”的形状,如下所示

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
       android:shape="rectangle">
       <solid android:color="@color/lightGrey" />
</shape>

您的
android:background
属性拼写错误:

android:Background=“@drawable/transparent_按钮_选择器”


“background”中缺少字母“n”

请尝试使用透明颜色而不是null。为什么不删除该空项?只是为了正确:
<item android:drawable="@drawable/..."
      android:state_pressed="true" />
<item
    android:state_pressed="true"
    android:drawable="@drawable/selected_state" />
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
       android:shape="rectangle">
       <solid android:color="@color/lightGrey" />
</shape>