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 trialBob Boursaw
2,047 PointsToast.makeText(this, "All done!", Toast.LENGTH_LONG).show(); No idea why this doesn't work.
I am apparently missing something from the course, but I don't understand what it is and have tried about 10 different variants of the code, all failing.
Toast allDoneToast;
allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show();
2 Answers
EVGENII MAMONTOV
7,666 PointsI think you've got incompatible types in your left and right sides of the equation. Toast.makeText(this, "All done!", Toast.LENGTH_LONG) - is the "Toast" type, great. But Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show() returns nothing, it's "void", and cannot be equal to allDoneToast variable of the"Toast" type. Try breaking your operator into two: allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG); allDoneToast.show();
Alex Johnson
6,067 PointsUpdate: Turns out that the reason you don't need a variable is because it's a static function of the Toast class so you can call it right from the class without instantiation.
I'm not sure why this didn't work in part one of the challenge, but to pass part three I was able to combine the first two lines into one without referencing a specific variable. This is what I put:
Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
allDoneToast.show();
Toast.makeText(this, "Second toast!", Toast.LENGTH_LONG).show();
Alex Johnson
6,067 PointsAlex Johnson
6,067 PointsThis helped me. Thanks!