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 trialsean tatenda jack
6,127 PointsLast but not least, create and show a simple Toast message that says "You pressed the back button!". Set the time for
Last but not least, create and show a simple Toast message that says "You pressed the back button!". Set the time for display using Toast.LENGTH_SHORT.
stuck
import android.os.Bundle;
public class PodcastActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_podcast);
}
@Override
public void onBackPressed () {
super.onBackPressed ();
Toast.makeText(this,"You pressed back the button", Toast.LENGTH_SHORT); }
}
Christopher Janke
11,054 Points"You pressed back the button" needs to be "You pressed back the button!" *! being added on. You might need to do Toast.LENGTH_SHORT).show(); if the "!" doesn't resolve the issue.
foxaice
12,038 PointsChristopher Janke "You pressed back the button" needs to be "You pressed back the button!" *! being added on. You might need to do Toast.LENGTH_SHORT).show(); if the "!" doesn't resolve the issue.
and you too have an error in the message. Pay attention to the order of word in task's message
5 Answers
Tarek M.Tolba
Courses Plus Student 3,613 PointsToast.makeText(this,"You pressed the back button!", Toast.LENGTH_SHORT).show();
the back button! instead of back the button. also don't forget .show()
sean tatenda jack
6,127 Pointsstill no luck here is the full code
import android.os.Bundle public class PodcastActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_podcast);
}
@Override
public void onBackPressed () { super.onBackPressed (); Toast.makeText(this,"You pressed back the button!,Toast.LENGTH_SHORT).show(); } }
Christopher Janke
11,054 PointsBahaha. Good thing you were paying closer attention than I was, I could only see the missing "!".
foxaice
12,038 Pointssean tatenda jack
Last but not least, create and show a simple Toast message that says "You pressed the back button!". Set the time for display using Toast.LENGTH_SHORT.
stuck
You have an error in the message. Try to copy it from the task of the challenge
Christopher Janke
11,054 Pointsreplace You pressed back the button! with this "You pressed the back button!" you are missing your ending " and you have the words "the" and "back" in the wrong order
sean tatenda jack
6,127 PointsThanks Janke, you made my day!!
mongst
10,841 PointsSpoiler Alert:
import android.os.Bundle;
public class PodcastActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_podcast);
}
@Override
public void onBackPressed () {
super.onBackPressed();
Toast.makeText(this,"You pressed the back button!",Toast.LENGTH_SHORT).show();
}
}
foxaice
12,038 Pointsfoxaice
12,038 PointsYou have an error in the message. Try to copy it from the task of the challenge