Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to change the image of a button with every click?
    primarykey
    data
    text
    <p>I created a <code>button</code> in the <code>layout</code> . In the <code>Drawable</code> folder I created a <code>XML file</code> named <code>btn01_state</code>. The <code>btn01_state.xml</code> is assigned to the <code>button</code> i created through "<code>android:background=@drawable/btn01_state</code>"</p> <p>Now, the <code>button</code> has a default <code>image</code> img1.when i <code>click</code> on the <code>button</code>, the image1 changes to img2, and once i release the clicked mouse button, the image2 again changed to img1 again.</p> <p><em>what i want to do is,to change the image of the button with evey click.</em></p> <p>for an example, initially btn01 has img01</p> <p>if btn01 is pressed==> set img of btn01 to img02 and keep img02 till the btn01 is pressed again. Now, btn01 has img02 on it.</p> <p>When btn01 is pressed, set img01 to btn01.</p> <p>I hope this clarified more what i want to do.</p> <p><strong>btn_selector</strong>:</p> <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:drawable="@drawable/android_blue" android:state_pressed="true" /&gt; &lt;item android:drawable="@drawable/ic_launcher" android:state_focused="true" /&gt; &lt;item android:drawable="@drawable/ic_launcher" /&gt; </code></pre> <p></p> <p><strong>main.xml</strong></p> <pre><code>&lt;Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/btn01" android:background="@drawable/btn01_state"/&gt; </code></pre>
    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