2012-02-27 86 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