Button color should not change when I release the button in Android -


<item android:state_focused="true" >      <shape>          <gradient              android:endcolor="#ff9900"              android:startcolor="#ff9966"              android:angle="270" />          <stroke              android:width="3dp"              android:color="#cccccc" />          <corners              android:radius="3dp" />          <padding              android:left="10dp"              android:top="10dp"              android:right="10dp"              android:bottom="10dp" />      </shape>  </item>      <item>              <shape>          <gradient              android:endcolor="#ffffff"              android:startcolor="#ffffff"              android:angle="270" />          <stroke              android:width="1dp"              android:color="#666666" />          <corners              android:radius="1dp" />          <padding              android:left="3dp"              android:top="3dp"              android:right="3dp"              android:bottom="3dp" />      </shape>  </item>  

above code have written filling borders of button black color.the same code using 3 buttons setting background.now, when click button1, red color appears , goes when releases. want red color visible, until press next button. though release button1 after press, red color should visible. red color should disappear when press other button.
can me in solving issue?
please me in sorting out issue?
in advance,

i afraid cannot complete goal through xml defines button states. because, afaik there no state defines button behavior after released (just normal, focused , pressed). normal state supposed.

but, can following:

  • let's original xml drawable drawable a
  • define new xml drawable b, has normal state defined wanted red button
  • after user presses button red because drawable says that
  • when user releases button, ensure stays red through change of drawable

    mybutton.setbackgrounddrawable(getresources().getdrawable(r.drawable.b));

  • when user presses button revert normal state through

    mybutton.setbackgrounddrawable(getresources().getdrawable(r.drawable.a));


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -