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
Tonnie FanadezUX Design Techdegree Graduate 22,796 Points
content_hourly_forecast.xml vs activity_hourly_forecast.xml
When I create the HourlyForecastActivity class, Android Studio creates 2 separate xml layouts file: activity_hourly_forecast.xml and content_hourly_forecast.xml.
The question is which xml file should I use and what is the difference between the 3 layouts files?
Hi Tonnie. It seems that you selected "Basic Activity" instead of "Empty activity" when you created that new HourlyForecastActivity.
"Empty Activity" creates an empty screen and comes with a single XML file: an empty ConstraintLayout. (It has a TextView displaying "Hello world" when you create a project with it).
"Basic Activity", on the other hand, creates a screen with a Floating Action Button (FAB) and generates 2 XML files: (using the names of your own created files)
The "activity" file (
activity_hourly_forecast.xml) is the CoordinatorLayout with the FAB, acting as a container for the other XML layout (the "content" file,
content_hourly_forecast.xml). You will see this tag in the layout:
<include layout="@layout/content_hourly_forecast" />,
which is where
content_hourly_forecast.xml is inserted.
The "content" XML file is the one you'd want to use to create your Hourly Forecast layout, if you really want to go with the "Basic Activity" here. To be honest, I don't think you'd need a FAB in that activity in this project (if I remember clearly), so you'd be better off deleting these 3 files and creating an "Empty Activity" instead.
Hope that helps :)