Home » Java » I Would Like To Have A Single Button Display A Different Line Of Text Each Consecutive Time It's Pressed in Android Studio

I Would Like To Have A Single Button Display A Different Line Of Text Each Consecutive Time It's Pressed in Android Studio

Posted by: admin July 12, 2018 Leave a comment

Questions:

I’m extremely new to coding, so apologies if this question is trivial or the answer is easily found somewhere. I have searched, but I cannot find anything that helps.

Basically, I’m trying to code a simple, 2 button app in Android Studio.

Button1 is meant to simply display a series of commands to the user via text box.

Button2 merely resets.

My problem is, I would like Button1 to change what’s displayed in the text view each time it is pressed, but I cannot figure out how to do so. I don’t want to make 6 or 7 buttons.

Basically I would like it to run as follows;

Text = “Pick a number”

user presses Button1

Text = “Add 15” (This is as far as I’ve gotten)

user presses Button1

Text = “Multiply times 5”

user presses Button1 etc. etc. etc.

If anybody could please explain or usher me in the right direction, I would be greatly appreciative.

Answers: