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

Michael B
Michael B
2,997 Points

Navigation Drawers and Fragments

Hi there,

I'm relatively new to Navigation Drawers, and have been following Ben's blog post about how to add one to a project. However, since I'm not starting my project from scratch and already have Fragments in the project, I'm a little confused about how the layout should be.

  1. Do Navigation Drawers always have to be in the MainActivity? Or can they be created in Fragments too?
  2. Suppose I created a Drawer in my MainActivity. I have a bunch of methods in my Fragment that I want to use depending on what drawers are clicked. So should I just be calling my Fragment's methods directly from MainActivity? It seems like this would create a lot of Context problems and some methods needing to be run on UI threads.

Thanks in advance!