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 trialFranco Pagliuso
633 PointsGetting Text from an Edit Text
what is going on at line private EditText mNameField:
No explanation is give in this video or previous videos on the track.
1 Answer
Jeff Wilton
16,646 PointsThat is a member variable which is used to temporarily store the value that the user enters into the name textbox in the app. After the start button is clicked, the value of the name textbox is reassigned to a String called "name" in the OnClickListener. For the sake of simplicity in this video, the name String is simply displayed as a Toast message.
Hope this helps!
Tommy Choe
38,156 PointsTommy Choe
38,156 PointsHey guys, I just want to make it clear that the line that Franco is referring to simply declares the member variable so that all other properties and methods in the class can access it. The member variable itself is actually initialized in the onCreate method before the setOnClickListener method. It simply gets initialized with a reference to nameEditText as soon as the app is created. The value that the user enters in the nameEditText text field is not yet being stored at this point.