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) Testing and Debugging Making a Toast

Uros Dukic
Uros Dukic
1,001 Points

code challenge problem

Set the Toast variable using the static makeText() method of the Toast class. Use the this keyword for the first parameter, the text "All done!" for the second parameter, and the constant Toast.LENGTH_LONG for the third parameter.

I tried so many different combinations from video about Toast and I can't get it....

8 Answers

Joannie Huang
Joannie Huang
6,195 Points

I think @dungray is correct. Try the below one and it should be workable.

Toast allDoneToast = Toast.makeText(this,"All done!",Toast.LENGTH_LONG);
Dai Phong
Dai Phong
20,395 Points

You need to create a Toast variable:

      Toast toast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
Doug Ray
Doug Ray
7,493 Points

Hey Uros

Sometimes coding can be frustrating for everyone dont worry. So most likely you are not assigning the toast variable to the toast value its asking so for example Toast allDoneToast; (this section declares a new toast variable but does not initialize it) then later you can initialize it with the suggested value like this allDoneToast = Toast.makeText(this,"All done!",Toast.LENGTH_LONG);. This will store our toast message in the toast variable for further use. (note we could also declare it in a single line like this (Toast allDoneToast = Toast.makeText(this,"All done!",Toast.LENGTH_LONG);. Let me know if this works for you !!

Hope this helps

Doug =D

Uros Dukic
Uros Dukic
1,001 Points

I tried that...It's not working.

Doug Ray
Doug Ray
7,493 Points

hmmmm it may be a small syntax error check for any typos or extra spaces or maybe a missing semi colon, you can also use the preview button next to the check work button and it should show you why its having a problem with your code.

Uros Dukic
Uros Dukic
1,001 Points

When I wrote this code above, in preview is shown;

JavaTester.java:39: cannot find symbol symbol : variable allDoneToast location: class JavaTester else if (allDoneToast.mConstructorCalled) { ^ JavaTester.java:42: cannot find symbol symbol : variable allDoneToast location: class JavaTester else if (!(allDoneToast.mContext instanceof JavaTester)) { ^ JavaTester.java:45: package allDoneToast does not exist else if (!allDoneToast.mText.toUpperCase().equals("ALL DONE!")) { ^ake JavaTester.java:48: cannot find symbol symbol : variable allDoneToast location: class JavaTester else if (allDoneToast.mDuration == LENGTH_LONG) { ^ JavaTester.java:51: cannot find symbol symbol : variable allDoneToast location: class JavaTester else if (allDoneToast.mDuration != Toast.LENGTH_LONG) { ^ 5 errors I re-watch this video about toast a lot and I can't find mistake..

Doug Ray
Doug Ray
7,493 Points

It seems like its finding your variable JavaTester.java:39: cannot find symbol symbol : variable allDoneToast location:. I would check that one more time to make sure it is declared like this Toast allDoneToast = Toast.makeText(this,"All done!",Toast.LENGTH_LONG);. if that doesnt work then there may be a technical issue with this code challenge

First of all, delete the code already written and paste in Toast allDoneToast = Toast.makeText(this,"All done!",Toast.LENGTH_LONG); . It should work.