I want to print something while my button is pressed (not after it is released).
At moment I have this, but it only works once…
button.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN) {
System.out.println("pressed");
return true;
}
return false;
}
});
System.out doesn’t work in an Android Device (won’t show you anything on the device)
and if you have a text view you can set the text on your
MotionEvent.ACTION_DOWNas you are already doing and on theMotionEvent.ACTION_UPyou set your text of your text view to empty.Something like this: