I haven't seen an answer for what I am trying to do. I want to update code for as long as I am pressing down on a button and when I let go, the code stops updating. Any advice helps please. Here's my code:
forward.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
// Code updates every frame
return true;
} else if (event.getAction() == MotionEvent.ACTION_UP){
// Code stops updating
return true;
}
return true;
}
});