I have an Imagebutton and I setColorFilter on ActionDOWN, but if user Slide the finger off the ImageButton, it remains with setColorFilter applied.
Question:
-
How to detect when finger slides off? Then I can apply setColorFilter(null);
ImageButton i1 = (ImageButton)v.findViewById(R.id.imageButton1);
i1.setOnTouchListener(new OnTouchListener() {@Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub ImageButton button = (ImageButton)v; String principal = "principal"; if (event.getAction() == MotionEvent.ACTION_DOWN) { button.setColorFilter(0x8066bbdd); return true; } else if (event.getAction() == MotionEvent.ACTION_UP) { button.setColorFilter(null); Intent i = new Intent(getActivity(), SubView.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.putExtra("query", principal); startActivity(i); return true; } return false; } });
You can use
MotionEvent.ACTION_OUTSIDEUPDATE 1:
If
MotionEvent.ACTION_OUTSIDEDoesn’t worked you can tryMotionEvent.ACTION_CANCEL