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


Andriod Development - Setting Up a document

In the treehouse lessons, there was a part where the teacher cut all the code from one page and placed it over/into another .xml file (i believe it was .xml)

Can some one help me with either: how to do this,, or video i am referring too.

Also why would we do this?

1 Answer

Hi Daniel, I think you may be referring to when the instructor created a new style. If you have certain style elements that are repeated in multiple layout files, you can refactor the repeated portions of the code into a new style that can be used across multiple layouts. You can create a new style by highlighting the repeated code, and then going to the top ribbon in Eclipse and clicking 'Refactor' --> 'Android' --> 'Extract Style'. Check out the video 'Creating a Style' for more information.

This helps with the DRY (Don't repeat yourself) principle used in programming. Hope this helps!