Java Android Show Toast
Toast myToast = Toast.makeText(this, "I'm a toast!", Toast.LENGTH_LONG);
myToast.show();
Mattalui
Toast myToast = Toast.makeText(this, "I'm a toast!", Toast.LENGTH_LONG);
myToast.show();
Toast.makeText( getBaseContext(), "message",Toast.LENGTH_SHORT).show();
Toast.makeText(requireContext(), "message", Toast.LENGTH_LONG;).show();
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
Toast toast;
private void toast(String msg) {
if (toast != null) toast.cancel();
toast = Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT);
toast.show();
}
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();