I have text field which has an onTouchListener attached to it. When i touch the text, ACTION_DOWN is fired and the text becomes black from its default white. And then I untouch ACTION_UP is fired and the text goes back to white.
However now when I touch and hold the text becomes black and stays like that, I want it so that when i touch and hold it should become black and then white again even while my finger is touching it.
How can I do that!?
I tried using some like this:
boolean clicked = true;
textfield.setOnTouchListener(new OnTouchListener(){
public void onTouch(View v, MotionEvent e){
if(m.getAction() == MotionEvent.ACTION_DOWN){
if(clicked){
// do something
clicked = false;
}
if(m.getAction() == MotionEvent.ACTION_UP){
clicked = true;
}
}
}
it doesnt work for some reason!!
So when you hold the text, you want it to go black then white (whilst you’re still holding it down)?
You could post a delayed message to a Handler to change the colour x milliseconds after the ACTION_DOWN event. You’ll have to manually set the colour rather than rely on the text colour state list as that’ll probably interfere with things.