Android Toast Create showToast(final Activity ctx, final String text, final int position, final boolean alive)

Here you can find the source of showToast(final Activity ctx, final String text, final int position, final boolean alive)

Description

show Toast

Declaration

public static void showToast(final Activity ctx, final String text,
         final int position, final boolean alive) 

Method Source Code

//package com.java2s;

import android.app.Activity;

import android.widget.Toast;

public class Main {
    public static void showToast(final Activity ctx, final String text,
            final int position, final boolean alive) {
        ctx.runOnUiThread(new Runnable() {

            @Override/*from   w  w  w . ja v a 2 s  . com*/
            public void run() {
                if (!alive) {
                    return;
                }
                Toast toast = Toast.makeText(ctx, text, Toast.LENGTH_SHORT);
                toast.setGravity(position, 0, 0);

                toast.show();
            }
        });
    }
}

Related

  1. showElapsed(long start, long end, Context ctx)
  2. formatToastDist(String message, int value, String unit)
  3. formatToastTemp(String message, int value, String unit)
  4. showMessage(final Activity activity, final String message)
  5. showToast(Activity activity, String message)
  6. makeToast(String msg, int length, Activity mainAct)
  7. displayToast(String message, Activity activity)
  8. showToast(Context context, String message)
  9. showToast(Context context, int id)