Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to resolve drawable in attribute "src"
    text
    copied!<p>I'm having a problem when trying to load various images to an image button using an xml file in the drawable-mdpi folder. It worked for one button but doesn't work for the other. The code works for the second image button but not the first, I get the error, " main.xml: Unable to resolve drawable "C:...workspace\AndroidAlarm\res\drawable-mdpi\keyEntry.xml" in attribute "src". I did the exact same thing in the first imageButton that I did for the second. The xml file for the second button (working one) looks like:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_pressed="true" android:drawable="@drawable/events_pressed" /&gt; &lt;!-- pressed --&gt; &lt;item android:drawable="@drawable/events" /&gt; &lt;!-- default --&gt; &lt;/selector&gt; </code></pre> <p>and for the one that doesn't work, it looks like:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_pressed="true" android:drawable="@drawable/key_entry_pressed" /&gt; &lt;!-- pressed --&gt; &lt;item android:drawable="@drawable/key_entry" /&gt; &lt;!-- default --&gt; &lt;/selector&gt; </code></pre> <p>The only difference between the two is the images being passed in. All the images are found in the drawabl-mdpi folder. I can't figure out why it works for the second image button but not the first. the xml code for the two buttons looks like:</p> <pre><code> &lt;LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"&gt; &lt;ImageButton android:id="@+id/imagebutton1" android:src="@drawable/keyEntry" android:background = "@android:color/transparent" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:scaleType = "fitXY" android:layout_marginTop = "50px" android:layout_marginLeft = "40px" android:layout_marginRight = "20px" android:layout_marginBottom = "50px" android:layout_weight="1"/&gt; &lt;ImageButton android:layout_marginTop="50px" android:layout_width="wrap_content" android:layout_marginRight="40px" android:id="@+id/imagebutton2" android:layout_weight="1" android:src="@drawable/events" android:layout_height="wrap_content" android:background="@android:color/transparent" android:layout_marginLeft="20px" android:layout_marginBottom="50px" android:scaleType="fitXY"&gt; &lt;/ImageButton&gt; &lt;/LinearLayout&gt; </code></pre> <p>Thanks in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload