Wednesday, 19 June 2013

Toast in Android.

We can say Toast is a notification message in a small popup,fills amount of space required for the message and automatically disappear after a timeout.
For instantiating a Toast, we can use makeText() have three paramteres.application Context, the text message, and the duration for the toast.
Code snippets to create a Toast message :
Toast.makeText(getApplicationContext(),"Please enter  username and password",Toast.LENGTH_LONG).show();
we can change the position of toast by using setGravity() have three paramteres like  a Gravity constant, an x-position offset, and a y-position offset.

Toast toast=Toast.makeText(getApplicationContext(), "Please enter  username and password", Toast.LENGTH_LONG);
 toast.setGravity(Gravity.CENTER|Gravity.RIGHT, 0, 0);;

We have two time duration variables in the class Toast.

1 comment:

  1. Hey Rano, great work man...but here is another vidio I found on Youtube on making Toast in Android..