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!
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
Hey 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
builder.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
Yeah, I learned that in the next lesson. Thanks.
Unfortunately, this.getString() is nowhere to be found in the pertinent lesson.
Also, 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.
Right on as long as you got it
Can 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.