PowenKo, Android, Tutorial 019-2, Dialog, Toast with position

August 25, 2011   ·   0 Comments

Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_LONG;

Toast toast = Toast.makeText(context, text, duration);
toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);
toast.show();

Tutorial_Dialog_ToastActivity/java

package com.powenko.Tutorial_Dialog_Toast_position;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.Toast;

public class Tutorial_Dialog_Toast_positionActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Context context = getApplicationContext();
        CharSequence text = "Hello toast! PowenKo.com";
        int duration = Toast.LENGTH_LONG ;

        Toast toast = Toast.makeText(context, text, duration);
        toast.setGravity(Gravity.TOP|Gravity.LEFT, 50, 50);
        toast.show();
    }
}

sample code:
Tutorial_Dialog_Toast_position

reference:

http://developer.android.com/guide/topics/ui/notifiers/toasts.html

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


Sorry, comments are closed on this post.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon