Showing Notifications / Toasts since m5-SDK

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Showing Notifications / Toasts since m5-SDK

Postby plusminus » Fri Feb 15, 2008 11:36 am

Showing Notifications / Toasts since m5-SDK


What you learn: Showing Notifications, since m5 called 'Toasts' has changed a bit. This shows the new way of doing so.

Difficulty: 0.5 of 5 :)

:idea: Questions/Problems: Simply post below...

What it will look like:
Image taken on old SDK:
Image


Description: There are two ways of showing a Toast:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. // public static Toast makeText(Context context, CharSequence text, int duration)
  2. Toast.makeText(this, "Some text here...", Toast.LENGTH_SHORT).show();
  3.  
  4. // or from a String-ID (text "behind" may also be formatted!)
  5.  
  6. // public static Toast makeText(Context context, int resId, int duration)
  7. Toast.makeText(this,R.string.id_of_maybe_formatted_text, Toast.LENGTH_LONG).show();
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

That's it :)


Regards,
plusminus
Last edited by plusminus on Tue Feb 19, 2008 4:13 pm, edited 1 time in total.
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby andbasti » Tue Feb 19, 2008 10:41 am

You can use show() to make the Toast visible 8):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. // public static Toast makeText(Context context, CharSequence text, int duration)
  2. Toast.makeText(this, "Some text here...", Toast.LENGTH_SHORT).show();
  3.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Best regards,

andbasti
andbasti
Freshman
Freshman
 
Posts: 4
Joined: Mon Jan 28, 2008 3:24 pm

Postby plusminus » Tue Feb 19, 2008 4:14 pm

andbasti wrote:You can use show() to make the Toast visible 8):

:roll: oops ^^
:arrow: corrected

thx
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

give me idea

Postby E.Jyothsna » Thu Feb 28, 2008 2:53 pm

By using Toast i displayed 1 message.Actually i want to display 2 or 3 messages one after another without clicking button.is this possible or nor?If yes means whats the way?
E.Jyothsna
Junior Developer
Junior Developer
 
Posts: 22
Joined: Thu Feb 28, 2008 12:25 pm
Location: chennai

Postby plusminus » Thu Feb 28, 2008 4:17 pm

Hello E.Jyothsna,

perhaps use a Thread with .sleep(X); or a Handler with postDelayed(Runnable,int).

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 6 guests