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() method.it 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() method.it 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);
 toast.show();


We have two time duration variables in the class Toast.
LENGTH_LONG & LENGTH_SHORT.

1 comment:

  1. Hey Rano, great work man...but here is another vidio I found on Youtube on making Toast in Android..
    http://www.youtube.com/watch?v=sVx46awjtFQ&list=PLonJJ3BVjZW6hYgvtkaWvwAVvOFB7fkLa&index=27

    ReplyDelete