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

Add a Button inside this RelativeLayout. Don’t add any attributes yet.

Hi, I'm on the code challenge above and trying to add a button inside the relative layout in xml, but getting the error "Bummer! Don't forget your opening and closing Button tags (or combined as one empty tag). Make sure your Button element is inside the opening and closing tags for the RelativeLayout." My code is below, can someone please help me figure out what I'm missing?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >
<button
      android:id="@android:id/button1"/>
        </RelativeLayout>

5 Answers

James Barnett
James Barnett
39,199 Points

Where is your closing button tag?

Looks like my code didn't make it, here it is:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" >

<button android:id="@android:id/button1"/>

</RelativeLayout>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" >

<button android:id="@android:id/button1"/>

</RelativeLayout>

Not sure why the code won't show up in the forum!

James Barnett
James Barnett
39,199 Points

Fixed the formatting on your code, make sure to check out the thread that Kevin Korte linked to.

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

One letter off! View elements in Android layout XML begin with capital letters. They are class names, essentially. :)

Thank you everyone!