I am generating random flashes of a button and I want to know what exact number is being chosen each time so I can eventually add them to an ArrayList
for a project I am undergoing.
TextView randomTextView;
Random r = new Random();
private void sequenceFunction() {
//Change Alpha from Fully Visible to Invisible
final Animation animation = new AlphaAnimation(1, 0);
//Duration - A Second
animation.setDuration(1000);
//Animation Rate
animation.setInterpolator(new LinearInterpolator());
animation.setStartOffset(250);
animation.setDuration(250);
//Repeat Animation
animation.setRepeatCount(r.nextInt(10));
// Reverse animation at the end so the button will fade back in
animation.setRepeatMode(Animation.REVERSE);
//Button 1 Flashes
final Button btn = (Button) findViewById(R.id.button);
btn.startAnimation(animation);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
view.clearAnimation();
}
});
}
I want to display the result of what ever random number has been generated via the randomTextView TextView
. This part is critical so that I know that the random function is working as it is supposed to. I have already tried
randomTextView.setText(r.nextInt(10));
However it didn't like it. Any ideas on how to get the random number selected would be greatly appreciated ?