Android XML ImageView changing Image -


I am trying some tasks and basically learning stuff, and I do not know why it is not working . I mean that when I touch the image changes at first R.Drawable.buttondown, but when I run my finger or leaves it, I do not work in other cases and the image does not change anymore. Can you tell me

  icon = (ImageView) findViewById (R.id.imageView1); icon.setOnTouchListener (New OnTouchListener () {@Override see public boolean onTouch (V, MotionEvent event) {switch (event.getAction ()) {case MotionEvent.ACTION_DOWN: icon.setImageResource (R.drawable.buttondown); break; case MotionEvent.ACTION_UP: icon.setImageResource (R.drawable.ic_launcher); break; case MotionEvent.ACTION_MOVE: icon.setImageResource (R.drawable.abc_ab_bottom_transparent_dark_holo); break;} return false;}  

you have to let Android that you need to return really is plenty of event.

 < Code> Public Boolean onTouch (see V, MotionEvent event) {Switch (event.getAct ion ()) {case MotionEvent.ACTION_DOWN: icon.setImageResource (R.drawable.buttondown); break; case MotionEvent.ACTION_UP: icon.setImageResource (R.drawable.ic_launcher); break; case motion event. Akshn_ MOVE: icon.setImageResource (R.drawable.abc_ab_bottom_transparent_dark_holo); break;} return true;}  

Docs:

it is true listener event, false otherwise

If you have been used To be honest, you are saying that you consumed this phenomenon and you are interested in others, if you make a false exit, then it will be on ACTION_DOWN because the event was not used.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -