

Toast toast = Toast.makeText(getApplicationContext(), "Simple Toast In Android", Toast.LENGTH_LONG) // initiate the Toast with context, message and duration for the Toast This method accepts three parameters: a Gravity constant, an x-position offset, and a y-position offset.īelow we Firstly initiate the Toast, set top and left gravity and then display it using show() method. setGravity(int,int,int): This method is used to set the gravity for the Toast. Toast toast = Toast.makeText(getApplicationContext(), "Simple Toast In Android", Toast.LENGTH_LONG) // initiate the Toast with context, message and duration for the Toastģ. This method is display the text which we create using makeText() method of Toast.īelow we Firstly initiate the Toast and then display it using show() method.

show(): This method is used to display the Toast on the screen. Toast toast = Toast.makeText(getApplicationContext(), "Simple Toast", Toast.LENGTH_LONG) // initiate the Toast with context, message and duration for the ToastĢ. Below we show the use of makeText() method of Toast in which we set application context, a text message and duration for the Toast.
