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 trialTimothy Hilley
2,292 Pointshey i just want to make sure im getting this right, newbie here (only one class in C, now learning java for android)
mFactsTextView = (TextView) findViewById(R.id.factTextView);
// Ok so this is a confusing one to start out
// mFactsTextView is a variable we are going to use to pull out the text and slap it on the screen
// the = is basically making mFactsTextView whatever is on the other side of the = (like a variable in algebra)
// (TextView) is helping out findViewById because findViewById is normally not used in this location, so its guiding it
// findViewById is a method, or tool, that is doing the "picking out and slapping onto the screen"
// R is the common files in java where the normal library is stored, giving the method juice and mechanics
// id is saying that its an id we are looking for (be literal)
// factTextView is the id we are looking for, and what is to be slapped onto the screen
MODERATOR EDIT: Added Markdown to post for readability. Please refer to the Markdown Cheatsheet for how to post code in the Community.
1 Answer
Philip Gales
15,193 PointsOverall you seem to have a good grasp. You will learn more as you continue using everything. Here are my two cents.
- 'mFactsTextView' is a special type of variable. Read about the 'm' on StackOverflow. Some people don't like it, but I have seen it used in large applications. Just use it.
- Understand that '=' in programming is NOT the same as algebra. In programming, it is assigning something to something else.
- The (TextView) is called casting and is a more advanced concept related to objects. http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html details more about this.