I m making an app and i want to use custom button skins . The code i use for changing background when the button is pressed is the following :
button3.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN) {
button3.setBackgroundResource(R.drawable.blue_buttonn);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
button3.setBackgroundResource(R.drawable.black_buttonn);
}else if (event.getAction() == MotionEvent.ACTION_HOVER_MOVE) {
button3.setBackgroundResource(R.drawable.black_buttonn);
}
return false;
}
});
This code is supposed to make a button blue when its being pressed and return it to black when released. It works but if you click the button and drag away from it the event ACTION_UP is not triggered . What event should i use in this case ?
I edited my code adding the event HOVER_MOVE which works when you move the finger out of the button. But because these buttons are inside an item of a custom list view if you move the finger outside of the current item the event HOVER_MOVE is not triggered.