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

chandlerknaus
chandlerknaus
1,635 Points

Toast allDoneToast

I cant seem to find what I am doing wrong O_o

Toast allDoneToast;
Toast.makeText(this,"All done!",Toast.LENGTH_LONG);
Stone Preston
Stone Preston
42,016 Points

see this post for instructions on posting code to the forum

5 Answers

Stone Preston
Stone Preston
42,016 Points

the task states: 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.

so you almost have it. you need to assign the return value of Toast.makeText to the allDoneToast variable

Toast allDoneToast = Toast.makeText(this,"All done!",Toast.LENGTH_LONG);
Daniel Hartin
Daniel Hartin
18,106 Points

Nothing at all, the code will run fine in an activity however if you are declaring the Toast as a variable on the line above I assume you mean to put

allDoneToast.makeText(this,"All done!",Toast.LENGTH_LONG);

p.s if it asks you to show it at the end you may need to add .show()

allDoneToast.makeText(this,"All done!",Toast.LENGTH_LONG).show()

Hope this helps

Daniel

chandlerknaus
chandlerknaus
1,635 Points

allDoneToast.makeText(this,"All done!",Toast.LENGTH_LONG); is wrong

Daniel Hartin
Daniel Hartin
18,106 Points

Okay, if you post the entire class I can take a look, the code I posted above will work based on the two lines you posted as the original question.

Is this code snippet from a code challenge if so I can go in and find out what it is asking you to do?

chandlerknaus
chandlerknaus
1,635 Points

Well I have tried a ton of things and none of them work >:x

Stone Preston
Stone Preston
42,016 Points

did you try my suggestion? I just tried the challenge as passed task 1 using the code I posted above. you are on task 1 correct?

chandlerknaus
chandlerknaus
1,635 Points

-_- I had to take Toast allDoneToast; out.... I might need to take a break for a little lol. Thank you guys for helping :)

Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);

use this..!!