iphone switch like button for android
<p>I have created a toggle button in android and I have used a selector to change the background that switches between the on and off backgrounds.</p>

<p>My problem is how to make the background remain in the state it will be clicked, for example, if I press on "on", the background should remain in "on" background state, but in my case as soon as I stop pressing the button, it reverts to the original background.</p>

<p>Does anyone has any idea how to implement it?</p>

<p>Here is my selector file:</p>

<pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:drawable="@drawable/off" /&gt; &lt;!-- default --&gt;
    &lt;item android:state_pressed="true" android:drawable="@drawable/on" /&gt; &lt;!-- on state --&gt;   
    &lt;item android:state_focused="false" android:drawable="@drawable/off" /&gt; &lt;!-- off state --&gt;
&lt;/selector&gt;
</code></pre>
