Note that there are some explanatory texts on larger screens.

plurals
  1. POsetBackgroundResource calls android.content.res.Resources$NotFoundException
    primarykey
    data
    text
    <p>I have <code>btn_solve_selector.xml</code> file in Drawable folder in order to set <code>Button</code> background programatically.</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:color="#ffff0000"/&gt; &lt;!-- pressed --&gt; &lt;item android:state_focused="true" android:color="#ff0000ff"/&gt; &lt;!-- focused --&gt; &lt;item android:color="#ff0000ff"/&gt; &lt;!-- default --&gt; &lt;/selector&gt; </code></pre> <p>With above code, I coded below code in <code>onCreate</code> of <code>MyActivity</code>.</p> <pre><code> _button1.setBackgroundResource(R.drawable.btn_solve_selector); </code></pre> <p>But the app was crashed with followed stacktrace.</p> <pre><code>Caused by: android.content.res.Resources$NotFoundException: File res/drawable/btn_solvenow_selector.xml from drawable resource ID #0x7f020085 .... at com.MyPackage.MyActivity.setMode(MyActivity.java:343) .... Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: &lt;item&gt; tag requires a 'drawable' attribute or child tag defining a drawable .... </code></pre> <p>It seems like the drawable xml file is failed to read even the file has <code>&lt;item /&gt;</code> inside of it and then fall-back to read android.content.res as a second trial. (I even checked with <code>com.MyPackage.R.drawable.btn_solve_selector</code> instead but failed).</p> <p>I removed and reinstalled the app but failed. What am I missing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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