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


fragment_main.xml & activity_main.xml

Hi. Can someone please help me understand easily why there's a fragment_main.xml in the latest android SDK? I've watched several tutorials also on android but they only use activity_main.html.

Enlighten me. :D

2 Answers

Ronald Muller
Ronald Muller
2,430 Points

Per the trainers comments in another members question they are working on a solution to address this change however the solution for now is to download the provided environment setup or delete the fragment_main.xml and code referring to it. You'll have to remove the references to each activity being made as fragments are added automatically (unless you use the provided project files/environment).

Check out Ben's reply to this post: https://teamtreehouse.com/forum/the-getsupportfragmentmanager-is-not-a-public-method-of-listactivity

Ronald Muller
Ronald Muller
2,430 Points

Also, for more on fragments: http://stackoverflow.com/questions/19876874/what-is-the-difference-between-acitvity-main-xml-and-fragment-main-xml-files-in

Overall http://stackoverflow.com/ is a great resource when you run into problems. You're more than likely not the only one running into the issue and this is a resource for asking questions from a community of programmers (new and advanced). As their site says: Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.