Questions tagged [android-toast]

A Toast is a momentary popup in Android which provides simple feedback about an operation.

Summary

A Toast is a momentary popup which provides simple feedback about an operation1. Toasts are added to an application's WindowManager and are not bound to an activity's UI; therefore, a Toast can remain visible after an Activity is navigated away from.

Toasts are typically displayed by using the makeText() method:

   // also supports Toast.LENGTH_LONG
Toast.makeText(getApplicationContext(), "some message", Toast.LENGTH_SHORT).show();

Sample Toast:-

enter image description here

It is important to note that the duration parameter requires either the LENGTH_LONG or LENGTH_SHORT . A custom millisecond value is not a valid duration parameter.

Custom Toasts

Toasts can use a custom View by using the setView() method3.

Usage

Toast messages should be as unobtrusive as possible4. Toasts should be used in situations that necessitate the user to be notified of certain background tasks such as a setting or draft being saved. Generally, Toasts should not exceed a single line of text.

Further reading

Toast overview

Toast developer guide

Toast code

Image Source and Brief guide

References:

1http://developer.android.com/guide/topics/ui/notifiers/toasts.html [Accessed on March 10, 2015]

2http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.2_r1/android/widget/Toast.java#Toast.0LENGTH_SHORT [Accessed on March 10, 2015]

3http://developer.android.com/guide/topics/ui/notifiers/toasts.html#CustomToastView [Accessed on March 10, 2015]

4http://developer.android.com/reference/android/widget/Toast.html [Accessed on March 10, 2015]

639 questions
-4
votes
2 answers

How can EditText returns users name in via Toast message when they write it in?

I am creating a simple quiz app and I need when users put their name in the EditText pop up a Toast message said "GoodLuck"+ Name.Could someone help on this? Here is my code: Thanks a lot! MainActivity.java public class MainActivity extends…
Eleni_M
  • 3
  • 7
-4
votes
3 answers

Android toast not showing inside onDestroy of Activity

My requirement is when user swipes(destroys) my application from Recent tab, I want to show a toast. For this I tried showing the toast in onDestroy of the MainActivity, But the toast does not show up. I am using the following code…
Rock
  • 47
  • 7
-4
votes
1 answer

Unable to show Toast

How do I show roomId In Toast? In my code (MainActivity) below, I am unable to show a Toast: package com.android.listviewexample; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import…
-4
votes
3 answers

How to show Toast in class which extends Activity

I have a Java Class in my Android project, where I wanted to separate facebook authorization from email authorization. Because of this line LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "public_profile")); I was…
-5
votes
3 answers

Android Toast not working (App crashes with a NumberFormatException)

I am not sure whether it is an IDE issue or my coding issue. This app is almost the same as the one that i followed online but my app keeps crashing. The Link to the source code : https://github.com/Gusri/AgeValidated . My Codes are almost the same…
user7499377
-5
votes
1 answer

Spell check with google dictionary

I am creating an application in which I have to check the word typed by user is correct or not using Google dictionary. If the word typed by user is correct, then a toast will be displayed. I am not getting any proper solution on my Google search.…
Mehdi1991
  • 91
  • 1
  • 10
-6
votes
1 answer

How to add 2 toast message in 1 java class?

I am trying to add another Toast message for my application, I've already made the first one when data is empty Toast message pop up and say " Sorry data still empty" and I would like make another one message pop up when there is data is available…
-6
votes
1 answer

For what this Android code is used?

I'm new on Android development, can you please explain me the following code and for what this Android code is it used? public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode,…
1 2 3
42
43