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 TextView

MICHAEL JONATHAN
MICHAEL JONATHAN
437 Points

android:id="+id/"

<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"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".SmsGrace"
        android:id="+id/">

    <TextView
        android:text="Did You Know?"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>

In the above script, the string : android:id="+id/"> is appearing as red letters in my activity_sms_grace.xml box. Please is the solution to this?

6 Answers

Hey Michael! You can just delete the android:id="+id/". It is used to set an identifier name for an element so that it can be accessed later through the method findViewById(), but I don't think you need it in your RelativeLayout. The reason it's appearing as red is because it's expecting you to specify the id name after the +id/, like this: android:id="+id/nameOfId".

Edit: Actually, looking at the final code for the "Build a Simple Android App", it looks like you will need an id for your RelativeLayout eventually. You'll probably add it later on in the course.

Stone Preston
Stone Preston
42,016 Points

try giving it an ID:

something like

tools:context=".SmsGrace"
android:id="+id/relativeLayout">
MICHAEL JONATHAN
MICHAEL JONATHAN
437 Points

remove it worked, but now i notice my Emulator doesnt come up again.I can only see it on the Start Task Manager, but it doesn't come up again. Do you have a solution to this....?

Stone Preston
Stone Preston
42,016 Points

do you have gradle build errors or anything like that in the console?

MICHAEL JONATHAN
MICHAEL JONATHAN
437 Points

Stone Preston no error on my gradle I can only see this under the event section It has a caution sign.but everyother thing looks very ok 10:08:40 Gradle build finished in 43 sec 10:08:52 Session 'app': running

Stone Preston
Stone Preston
42,016 Points

try restarting android studio. are you using genymotion?

MICHAEL JONATHAN
MICHAEL JONATHAN
437 Points

Bro,i have restarted like 3 times. No am using AVD manager

Stone Preston
Stone Preston
42,016 Points

you should definitely think about using genymotion instead. its much faster and more responsive. makes everything a whole lot easier.

MICHAEL JONATHAN
MICHAEL JONATHAN
437 Points

Please can u tell me how to using that...I actually skipped it

Stone Preston
Stone Preston
42,016 Points

the getting started with genymotion section of this course will walk you through setting it up. its pretty easy to install.

MICHAEL JONATHAN
MICHAEL JONATHAN
437 Points

will i need to start all over again?