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 Build a Simple Android App (2014) Creating the Screen Layout Adding a Button

Shafique Mohammed
seal-mask
.a{fill-rule:evenodd;}techdegree
Shafique Mohammed
Front End Web Development Techdegree Student 13,625 Points

I added a Button element

Hi can anyone help me please. I added button element, am bit confuse to what do I Copy and paste the TextView element

activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" >

  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

   <button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</RelativeLayout>
Lukas Baumgartner
Lukas Baumgartner
14,817 Points

Could you specify your question? I don't really know what you want to do...

6 Answers

Shafique Mohammed
seal-mask
.a{fill-rule:evenodd;}techdegree
Shafique Mohammed
Front End Web Development Techdegree Student 13,625 Points

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

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" />

</RelativeLayout>

Shafique Mohammed
seal-mask
.a{fill-rule:evenodd;}techdegree
Shafique Mohammed
Front End Web Development Techdegree Student 13,625 Points

We just saw how adding a Button generates the XML for us. Now let's write the XML by hand. Start simple by adding a Button element. Copy and paste the TextView element and just change 'TextView' to 'Button'.

Lukas Baumgartner
Lukas Baumgartner
14,817 Points

Write:

 Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

Always check your spelling ;) You wrote a small 'b' instead of a 'B'. I hope that was the problem

with a "smaller symbole" in front of Button. It somehow won't let me write it properly

Shafique Mohammed
seal-mask
.a{fill-rule:evenodd;}techdegree
Shafique Mohammed
Front End Web Development Techdegree Student 13,625 Points

I need to add a button element which can add, the bit I don't understand is what code do I need to copy and paste. I already try to copy the TextView element and change it to button this does not work

Lukas Baumgartner
Lukas Baumgartner
14,817 Points

No problem :)

If you do what they tell you you should, and you are absolutley certain that you did it right, it is most likely a spelling mistake on your side ;)