Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialihssan hashem
2,730 PointsHow is it looping?
HI, I don't understand how is this working, I thought that we will need a loop to iterate every time we click the button, but this doesn't seem the case here! How is the program able to allow more than one click each time we run it? What I mean, if the program is reading every line, without looping, it will get to the last line and exit the program before we are able to click another click!
thanks
1 Answer
Micheal Ammirati
5,377 PointsThe code inside the onClickListener for the button will run every time the user clicks the button. It is attached to the button view object and "listens" for a click. Once that click is made it will run the code