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 a Simple Android App (retired 2014) Getting Started with Android Introduction to Methods and Classes

MainActivity.java changes in between video without explanation

Hi guys,

I'm not sure if I'm missing something but in between the 'Inital Layout' video and the 'Introduction to Methods and Classes' video the code in the MainActivity.java file changes and as far as I can tell there is no explanation as to why.

Any ideas?

3 Answers

Masum Bergmann
PLUS
Masum Bergmann
Courses Plus Student 4,129 Points

Hi Aaron,

In the Initial Layout Video we move the entire fragment_main.xml code into activity_main.xml (replacing the existing code there) and deleting the fragment_main.xml file. @ 3:25 in the video, Ben deletes couple of sections of code in MainActivity.java which still refer to the just deleted fragment_main.xml file.

Is that the code change you were referring to? It helps to watch the video! ;-)

Hi Masum,

Thanks for your reply but that's not what I meant. I've definitely watched the videos and even after deleting the unnecessary code, if you check out the code in the Initial layout video @ 4.30 and compare it to the code in the Introduction to Methods and Classes video @ 0.45 you can see it's changed and I can't see in the video why or how we got to that.

It's not a problem for me now though, I just downloaded the source files for the lesson and continued with the new code.

Thanks again dude

Masum Bergmann
PLUS
Masum Bergmann
Courses Plus Student 4,129 Points

Ahh... I see what you mean! ;-) Good eye!!

For starters, it seems that he deleted some comments and with regards to the deleted onOptionsItemSelected() method, it looks like that particular method is used for menu navigation, which we don't need for our app. I just checked my code and I still have it in there, so it doesn't seem to make a difference either way.

I suppose he just took it out of his code so it would look neater and be less distracting for us!

Cheers, Masum!