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 Blog Reader Android App Adapting Data for Display in a List Handling Errors Using Dialogs

Sixto Rios
Sixto Rios
1,864 Points

Compiler errors on code challenge part 3

This is compilers I keep getting. When you look at the video and the API for Android though, those methods do exist where they accept a string resource id as a parameter

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

1 Answer

Erin Kabbash
Erin Kabbash
5,210 Points

Can you post your code please? Seems like you maybe trying to assign an int to a string and it needs to be cast first.

Sixto Rios
Sixto Rios
1,864 Points

I figured out what's up. Apparently Treehouse doesn't have the method implemented to accept a resource ID as a parameter. Here's my code, it works because it is in the API but Treehouse doesn't have it.

/*** This code is an excerpt from a class that extends Activity ***/ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.dialog_title); builder.setMessage(R.string.dialog_message);