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 trialMICHAEL JONATHAN
437 Pointsandroid: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
Kristen Law
16,244 PointsHey 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
42,016 Pointstry giving it an ID:
something like
tools:context=".SmsGrace"
android:id="+id/relativeLayout">
MICHAEL JONATHAN
437 Pointsremove 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
42,016 Pointsdo you have gradle build errors or anything like that in the console?
MICHAEL JONATHAN
437 PointsStone 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
42,016 Pointstry restarting android studio. are you using genymotion?
MICHAEL JONATHAN
437 PointsBro,i have restarted like 3 times. No am using AVD manager
Stone Preston
42,016 Pointsyou should definitely think about using genymotion instead. its much faster and more responsive. makes everything a whole lot easier.
MICHAEL JONATHAN
437 PointsPlease can u tell me how to using that...I actually skipped it
Stone Preston
42,016 Pointsthe getting started with genymotion section of this course will walk you through setting it up. its pretty easy to install.
MICHAEL JONATHAN
437 Pointswill i need to start all over again?