RSS

Making a toast

27 Jun

One of the components that android phones come with is the Toast. It sort of gives information to the user about something, just like in the above case. Its supposed to inform us that the wallpaper has been set. It’s really reassuring, I gotta say. Ok so, there are a few ways you can do it (its really one way actually but you’ll see):

Context context = getApplicationContext();
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context,"This is a toast that will say: Wallpaper set",duration);
toast.show();

or

Toast.makeText(getApplicationContext(), "This is a toast that will say: Wallpaper set", Toast.LENGTH_LONG).show();

So as you can see its the Toast.makeText() that builds the toast. It takes three parameters: the context, text to be displayed and the duration of display. You can still make custom toast that display images and other stuff as opposed to text alone. So watch out for this space.

click here to view the full app code.

Advertisements
 
1 Comment

Posted by on June 27, 2012 in Android, Android tutorials, Code

 

Tags:

One response to “Making a toast

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: