java - How to change the button upon click ,and revert back to normal upon release the button? -
I want my image to change the image until I press and hold down the button and when I I want to back it back to the original image, is there a way to do it?
bTen.setOnClickListener (New View. OnClickListener () {@Override Public Zero is OnClick (see V) {bTen.setBackgroundResource (R.drawable.press); s1 + = "E"; TxtView.setText (s1);}}); I have used the above code, but when I release my finger, I do not return to the original.
You can create your own selector example and add it as style for your button (xml ):
& lt; XML version = "1.0" encoding = "utf-8" & gt; & Lt; Selector xmlns: Android = "http://schemas.android.com/apk/res/android" & gt; & Lt ;! - disabled - & gt; & Lt; Item Android: Dragon = "@color / ..." Android: state_enabled = "false" /> & Lt ;! - pressed - & gt; & Lt; Item Android: Dragon = "@color / ..." Android: state_pressed = "true" /> & Lt ;! - default - & gt; & Lt; Item Android: Dragon = "@color.....& gt; & Lt; / Item & gt; & Lt; / Selector & gt;
Comments
Post a Comment