Wednesday, December 26, 2012

Android Simple Toast Example


 SIMPLE TOAST



To display a simple toast, we need to makeText for that toast & then call show() to display it.
To use makeText(), we need to send 3 arguments.
1) Context
2) Text to display in toast
3) Duration How much time its need to be show
At last call show() to display toast.


SOURCE CODE is

package com.ToastExample;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class ToastExample extends Activity
{
                public void onCreate(Bundle savedInstanceState)
                {
                                super.onCreate(savedInstanceState);
                                setContentView(R.layout.main);

                                 Toast msg = Toast.makeText(ToastExample.this,
                                                "YOUR TEXT HERE", Toast.LENGTH_LONG);
                                msg.show();

                 }
}



The OUTPUT will be

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFJBXEQNitIh-JK-5uKhBzCubfZJYFv_tLtOUBzf_7ZRFgV2qqU_JCsqR0r8xOPKISk0rppvYW1IVCUh9BA_0t5cJBctN1ZYiBInum9pU9R4DmCR1y0Lcb0H63J35UkmIi9fUIy_KBb8g/

No comments:

Post a Comment