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 trialKendrick Ledet
Courses Plus Student 2,493 PointsHey guys, just wanted to let you know that there is an error in this lesson. Using completely correct syntax
JavaTester.java:70: setTitle(java.lang.String) in android.app.AlertDialog.Builder cannot be applied to (int) builder.setTitle(R.string.dialog_title); ^ JavaTester.java:71: setMessage(java.lang.String) in android.app.AlertDialog.Builder cannot be applied to (int) builder.setMessage(R.string.dialog_message); ^ 2 errors
6 Answers
cbcbcb
16,560 Pointsbuilder.setTItle( R.string.dialog_title ); ///Your code
A resource ID is an integer. You need to return a String. The resource id doesn't instantiate an object of String at runtime. You have to do that.
builder.setTItle( this.getString( R.string.dialog_title ) ); //Correct code
Kendrick Ledet
Courses Plus Student 2,493 PointsYeah, I learned that in the next lesson. Thanks.
Unfortunately, this.getString() is nowhere to be found in the pertinent lesson.
Kendrick Ledet
Courses Plus Student 2,493 PointsAlso, interestingly enough, my original code works as is on my system....I see that's because there are two different AlertDialog.Builder.setMessage() signatures...one does indeed take a resource ID int. So the issue is really with the Treehouse compiler, and my code is still correct, just not for their compiler. Just a heads up.
cbcbcb
16,560 PointsRight on as long as you got it
cbcbcb
16,560 PointsCan we close this question? I think it has been answered because the original poster has acknowledged that the solution provided was able to fix his problem but doesn't like the fact that an alternative method for solving it was not accepted by the TreeHouse code challenge parser.
André Sanna Taylor
2,612 PointsHi Ben Jakuben !Can you check if there is any compiler problem in this task? thank you :)
Ben Jakuben
Treehouse TeacherThanks for the heads up! I will take a look.