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 trial

Android Build an Interactive Story App (Retired) User Input Getting Text from an EditText

Duarte Reis
seal-mask
.a{fill-rule:evenodd;}techdegree
Duarte Reis
Python Web Development Techdegree Student 775 Points

Why we declare the member variables before the on create method? I don't see the reason for this.

Can someone explain?

When we create the mVariables before the On create method, where are they created? Shouldn't I create another activity (as it was done in the Fun Facts project) so that variables refer to other activity.

Thanks and sorry for the noob question! ;)

It is a matter of scope. If we declare a variable from within a method, the variable can only be accessed within that method. When we declare the variable in a class but outside a method, the variable can be used anywhere within the class and is not dependent on any given method.