Android Toast Create showToast(final Context context, final String string)

Here you can find the source of showToast(final Context context, final String string)

Description

show Toast

License

Apache License

Declaration

private static void showToast(final Context context, final String string) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;

public class Main {
    private static void showToast(final Context context, final String string) {
        Handler handler = new Handler(Looper.getMainLooper());

        handler.post(new Runnable() {

            @Override/*  w  w  w  . ja  v a 2 s  .  c o m*/
            public void run() {
                Toast.makeText(context, string, Toast.LENGTH_LONG).show();

            }
        });
    }
}

Related

  1. showToast(Context context, int id)
  2. showToast(Context context, int stringId)
  3. showToast(String text, Context context)
  4. showToast(final Context context, String text)
  5. showToast(final Context context, final String message)
  6. showToast(final Context context, final int resId)
  7. showToast(final Context ctx, final Handler handler, final String text, final int duration)
  8. showToast(final Context ctx, final Handler handler, final int id, final int duration)
  9. showToast(final String toast, final Context context)