imageview - OnTouch change Image in XML - android -


I have an XML file in the graphical folder, which I want to use as an ImageView src. Here's the 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_pressed = "true" android: drawable = "@ drawable / home2" /> & Lt; Item Android: state_pressed = "false" android: drawable = "@drawable / home1" & gt; & Lt; / Item & gt; & Lt; / Selector & gt;  

As you can see that the image is pressed every time, it will turn the image into another image, but for some reason it does not work properly. It just shows me the default image and when I press the image, it does not switch.

In addition, I tried to put this code but I got the same result:

   & Lt; Item Android: Dragon = "@ Draubel / Home 1" & gt; & Lt; / Item & gt; & Lt; / Selector & gt;  

What can be the solution?

For example you press press image = Home 1 when image = Home 2 is pressed And when the user changes the remoting image = Home 2, then he can not change it again. If so, then you can use this code.

  & lt; Item android: state_pressed = "true" android: drawable = "@ drawable / home2" />  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -