One Button Has Multiple State

When you use a button with Two states, you just simply use a variable as boolean type (True/False).

But when you need a button with multiple states, How to do this?

That’s very simple by using the following statement:

 

<br />int state = 0

yourClickEvent(){
state = (state + 1) % numberOfStateYouWant
}

 

an Example when  numberOfStateYouWant = 3

drrg

 

Cheers.

Huy Nguyen

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s