2012-02-27 87 views
0

我的XML文件是如下.. ADT问我, “无法解析文件E:\应用程序\维沙尔\工作区\ MyApp的\水库\绘制\ day.xml”无法解析XML文件绘制

<?xml version="1.0" encoding="utf-8"?> 
    <selector xmlns:android="http://schemas.android.com/apk/res/android">  
    <item 
     android:state_pressed="false" 
     android:state_focused="false" 
     android:background="@android:color/transparent" 
     android:drawable="@drawable/dayoff"/>  

    <item 
     android:state_pressed="false" 
     android:state_focused="true"  
     android:background="@android:color/transparent" 
     android:drawable="@drawable/dayon"/> 

    <item 
     android:state_pressed="false" 
     android:state_focused="true"  
     android:background="@android:color/transparent" 
     android:drawable="@drawable/dayon"/>  

    <item 
     android:drawable="@drawable/dayon"/>    
    </selector> 

这里dayoff和dayon被绘制文件夹下的两个png图片..

哪里是我错了?建议plz。

+0

检查此示例http://developer.android.com/resources/tutorials/views/hello-formstuff.html#CustomButton – Ajay 2012-02-27 08:03:55

+0

我认为你需要把这个day.xml放到你的res/menu /文件夹中。 – 2012-02-27 08:12:20

+0

@PadmaKumar @PadmaKumar不工作.. – 2012-03-01 06:42:10

回答

0

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

<item 
    android:state_focused="true"  
    android:drawable="@drawable/dayon"/>  

<item 
    android:drawable="@drawable/dayoff"/>   
</selector> 
+0

尝试相同..仍然相同的错误 – 2012-02-28 06:30:09

0

你的代码是100%正确的..我想你正在使用可能已损坏的PNG ...

OR

检查是否有启动前的任何空间day.xml文件.....

+0

你能解释哪个空间.. – 2012-02-28 06:29:46

+0

<?xml version =“1.0 “encoding =”utf-8“?> 检查xml的开始标记之前是否有空格。 – Mohanish 2012-02-28 08:37:04