Reputation: 197
I am new to android development. I'm trying to make a program that the user selects red green and blue values to make a custom color. I have everything working the way I want but one pesky thing. When the user holds a value down or up button I want the values to keep changing. So far this is what I got
redUpButton.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
if(redColorValue<250){
redColorValue+=5;
redTextField.setText(""+redColorValue/5);
mainColorLabel.setTextColor(Color.rgb(redColorValue, greenColorValue, blueColorValue));
}//ends if
return true;
}//ends method
});//ends click listener
but when I do this it only changes my values once. How do i get it to keep changing the values while I hold the button. I assume I need a while statement but nothing I try works.
Upvotes: 0
Views: 593
Reputation: 2081
OnLongClickListener
is an event like any other which is only called once per press. Hence, the event in not a looping mechanism to increment something but only a custom event for long touch
Instead you can try the onTouchListener
with onKeyListener
to achieve the above
See this example here
Upvotes: 1