Best code examples for Toast show method (android.widget.Toast.show)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Toast show method.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Toast show examples from Open Source projects
This code example shows how to use the following methods: setDuration, setView, show
27:	Toast toast = new Toast(this); 
28:	toast.setDuration(Toast.LENGTH_LONG); 
29:	toast.setView(toastLayout); 
30:	toast.show(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setDuration, setGravity, setView, show
94:	Toast toast = new Toast( mContext.getApplicationContext() ); 
-
96:	toast.setGravity( gravity, 0, 0 ); 
97:	toast.setDuration( duration ); 
98:	toast.setView( layout ); 
99:	toast.show(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setDuration, setGravity, setView, show
103:	final Toast myToast = new Toast(mActivity); 
-
106:	myToast.setView(myView); 
107:	myToast.setDuration(Toast.LENGTH_SHORT); 
108:	myToast.setGravity(Gravity.BOTTOM | Gravity.CENTER, 0, 0); 
109:	myToast.show(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getXOffset, getYOffset, setGravity, show
113:	mToast.setGravity(Gravity.CENTER, mToast.getXOffset() / 2, mToast.getYOffset() / 2); 
114:	mToast.show(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setText, show
308:	mToast.setText(context.getString(message)); 
309:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: show
86:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: show
40:	toast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setDuration, setGravity, setView, show
88:	mToast.setView(mView); 
89:	mToast.setDuration(Toast.LENGTH_SHORT); 
90:	mToast.setGravity(Gravity.TOP, 0, 0); 
91:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setDuration, setGravity, setView, show
88:	mToast.setView(mView); 
89:	mToast.setDuration(Toast.LENGTH_SHORT); 
90:	mToast.setGravity(Gravity.TOP, 0, 0); 
91:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setDuration, setView, show
18:	Toast toast = new Toast(context); 
-
22:	toast.setView(toastLayout); 
23:	toast.setDuration(length); 
24:	toast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getXOffset, getYOffset, setGravity, show
114:	mToast.setGravity(Gravity.CENTER, mToast.getXOffset() / 2, mToast.getYOffset() / 2); 
115:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setText, show
43:	toast.setText(sText); 
44:	toast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setDuration, setGravity, show
52:	mToast.setGravity(Gravity.CENTER, 0, 0); 
53:	mToast.setDuration(length); 
54:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setText, show
99:	lastText.setText(text); 
-
101:	lastText.show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setGravity, show
84:	tooltip.setGravity(Gravity.CENTER, 0, 0); 
85:	tooltip.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: show
61:	mToasts.put(id, t = Toast.makeText(this, id.intValue(), Toast.LENGTH_SHORT)); 
62:	t.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setText, show
69:	toast.setText(msg); 
70:	toast.show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setText, show
69:	toast.setText(msg); 
70:	toast.show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: cancel, show
207:	toast.cancel(); 
208:	toast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setText, show
27:	mToast.setText(text); 
-
29:	mToast.show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: show
73:	toast.show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: show
213:	toast.show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: show
102:	toast.show(); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: show
54:	mToast.show(); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: show
156:	toast.show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: show
109:	mToast.show(); 
Full Snippet Info
4
CodeRank
Related Toast show Questions & Answers:
Other Toast show Examples
41:	  @Override
42:	  public boolean onOptionsItemSelected(MenuItem item) {
43:	    Toast.makeText(this, "Just a test", Toast.LENGTH_SHORT).show();
44:	    return true;
45:	  }

Read More

73:	  public void onProviderEnabled(String provider) {
74:	    Toast.makeText(this, "Enabled new provider " + provider,
75:	        Toast.LENGTH_SHORT).show();
76:	
77:	  }
-
80:	  public void onProviderDisabled(String provider) {
81:	    Toast.makeText(this, "Disabled provider " + provider,
82:	        Toast.LENGTH_SHORT).show();
83:	  }
84:	}

Read More

24:	        .hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
25:	      Toast.makeText(this, "No camera on this device", Toast.LENGTH_LONG)
26:	          .show();
27:	    } else {
28:	      cameraId = findFrontFacingCamera();
-
29:	      if (cameraId < 0) {
30:	        Toast.makeText(this, "No front facing camera found.",
31:	            Toast.LENGTH_LONG).show();
32:	      } else {
33:	        camera = Camera.open(cameraId);

Read More

67:						Toast.makeText(getApplicationContext(),
68:								"Please enter category name", Toast.LENGTH_SHORT)
69:								.show();
70:					}
71:				}

Read More

42:						Toast.makeText(getApplicationContext(),
43:								"Please enter category name", Toast.LENGTH_SHORT)
44:								.show();
45:					}
46:				}

Read More

76:				Toast.makeText(getApplicationContext(),
77:						"Sorry! Your device doesn't support camera",
78:						Toast.LENGTH_LONG).show();
79:				// will close the app if the device does't have camera
80:				finish();
-
164:					Toast.makeText(getApplicationContext(),
165:							"User cancelled image capture", Toast.LENGTH_SHORT)
166:							.show();
167:				} else {
168:					// failed to capture image
-
169:					Toast.makeText(getApplicationContext(),
170:							"Sorry! Failed to capture image", Toast.LENGTH_SHORT)
171:							.show();
172:				}
173:			} else if (requestCode == CAMERA_CAPTURE_VIDEO_REQUEST_CODE) {
-
180:					Toast.makeText(getApplicationContext(),
181:							"User cancelled video recording", Toast.LENGTH_SHORT)
182:							.show();
183:				} else {
184:					// failed to record video
-
185:					Toast.makeText(getApplicationContext(),
186:							"Sorry! Failed to record video", Toast.LENGTH_SHORT)
187:							.show();
188:				}
189:			}

Read More

Toast Class Overview
A toast is a view containing a quick little message for the user. The toast class helps you create and show those.

When the view is shown to the user, appears as a floating view over the application. It will never receive focus. The user will probably be in the middle of typing something else. The idea is to be as unobtrusive as possible, while still showing the user the information you want them to see. Two examples are the volume control, and the brief message saying that your settings have been saved. The easiest way to use this class is to call one of the static methods that constructs everything you need and returns a new Toast object. Developer Guides For information about creating Toast notif...
show Method Overview
Show the view for the specified duration.
See Also
  • cancel
    Close the view if it's showing, or don't show it if it isn't showing yet.
  • getXOffset
    Return the X offset in pixels to apply to the gravity's location.
  • getYOffset
    Return the Y offset in pixels to apply to the gravity's location.
  • makeText
    Make a standard toast that just contains a text view with the text from a resource.
  • setGravity
    Set the location at which the notification should appear on the screen.
  • setText
    Update the text in a Toast that was previously created using one of the makeText() methods.