Note that there are some explanatory texts on larger screens.

plurals
  1. POanimation-list not animating initially
    text
    copied!<p>I have a checkbox that should look like a green light when checked and a red blinking light when unchecked. To do this I created a selector called connected_selector.xml.</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_checked="true" android:drawable="@drawable/green_button" /&gt; &lt;item android:state_checked="false" android:drawable="@drawable/red_button_blinking" /&gt; &lt;item android:drawable="@drawable/red_button_blinking" /&gt; &lt;/selector&gt; </code></pre> <p>The green_button is simply a png and the red_button_blinking is an animation-list of pngs.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"&gt; &lt;item android:drawable="@drawable/red_button" android:duration="500" /&gt; &lt;item android:drawable="@drawable/red_button_lit" android:duration="500" /&gt; &lt;/animation-list&gt; </code></pre> <p>The checkbox's background is set to @drawable/connected_selector. If the checkbox is initially unchecked, it doesn't blink, it just shows the @drawable/red_button. However if I check the box and then uncheck it, the checkbox will animate correctly.</p> <p>How can I make the animation start initially since the checkbox will be initially unchecked? I guess I could try to start the animation manually in code, but I don't think that should be necessary.</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