Example usage for android.widget Toast getView

List of usage examples for android.widget Toast getView

Introduction

In this page you can find the example usage for android.widget Toast getView.

Prototype

public View getView() 

Source Link

Document

Return the view.

Usage

From source file:com.monmonja.library.utils.ViewUtils.java

public static void makeToast(Context context, int resId) {
    TypedValue tv = new TypedValue();
    int offsetY = 0;
    if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        offsetY = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
    }/*from  w w w  .  ja va2  s .  c o m*/

    Toast toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    View view = toast.getView();
    view.setBackgroundColor(context.getResources().getColor(R.color.toast_background));
    TextView text = (TextView) view.findViewById(android.R.id.message);
    text.setTextColor(context.getResources().getColor(android.R.color.white));
    toast.show();
}

From source file:com.bhb27.isu.tools.Tools.java

public static void DoAToast(String message, Context context) {
    Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
    TextView view = (TextView) toast.getView().findViewById(android.R.id.message);
    if (view != null)
        view.setGravity(Gravity.CENTER);
    toast.show();/*from  w ww.  j a  v  a  2 s  . c o  m*/
}

From source file:com.pdftron.pdf.utils.Utils.java

public static void showToast(Context context, String string, int duration) {
    if (context != null) {
        Toast toast = Toast.makeText(context, string, duration);
        if (Utils.isRtlLayout(context)) {
            toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL);
        }//from w  w  w .j av a 2s. c om
        toast.show();
    }
}

From source file:com.pdftron.pdf.utils.Utils.java

public static void showToast(Context context, int stringId, int duration) {
    if (context != null) {
        Toast toast = Toast.makeText(context, stringId, duration);
        if (Utils.isRtlLayout(context)) {
            toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL);
        }/*  w  w  w . j  a v  a2  s . co  m*/
        toast.show();
    }
}

From source file:com.pdftron.pdf.utils.Utils.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static void showToast(Context context, String string) {
    if (context != null) {
        Toast toast = Toast.makeText(context, string, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER, 0, 0);
        if (Utils.isRtlLayout(context)) {
            toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL);
        }/*from  w  w  w  .  ja  va  2 s .c  om*/
        toast.show();
        return;
    }
}

From source file:com.pdftron.pdf.utils.Utils.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static void showToast(Context context, int stringId) {
    if (context != null) {
        Toast toast = Toast.makeText(context, stringId, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER, 0, 0);
        if (Utils.isRtlLayout(context)) {
            toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL);
        }//from   w  w w.ja v  a 2  s  .  c  om
        toast.show();
    }
}

From source file:com.pdftron.pdf.utils.Utils.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Toast showToast(Context context, Toast toast, String text, int duration) {
    if (toast != null) {
        toast.cancel();/*from  www.j  a  v  a2 s.c o m*/
    }
    toast = Toast.makeText(context, text, duration);
    if (Utils.isRtlLayout(context)) {
        toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL);
    }
    toast.show();
    return toast;
}

From source file:com.pdftron.pdf.utils.Utils.java

public static Toast showToast(Context context, Toast toast, int stringId, int duration) {
    if (toast != null) {
        toast.cancel();/*from   w w  w  .ja  va 2  s .c  o  m*/
    }
    toast = Toast.makeText(context, stringId, duration);
    if (Utils.isRtlLayout(context)) {
        toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL);
    }
    toast.show();
    return toast;
}

From source file:com.longle1.facedetection.TimedAsyncHttpResponseHandler.java

@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
    Log.e("RTT", String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms");
    String msg = "RTT: " + String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms";
    Toast mToast = Toast.makeText(mContext, msg, Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.TOP, 0, 0);
    TextView v = (TextView) mToast.getView().findViewById(android.R.id.message);
    v.setTextColor(Color.RED);//from  w ww. j av a 2 s.  c  om
    mToast.show();
}

From source file:org.openobservatory.ooniprobe.activity.MainActivity.java

public void showToast(int string, boolean success) {
    Toast toast = Toast.makeText(this, string, Toast.LENGTH_LONG);
    View view = toast.getView();
    view.setBackgroundResource(success ? R.drawable.success_toast_bg : R.drawable.error_toast_bg);
    TextView text = (TextView) view.findViewById(android.R.id.message);
    text.setGravity(Gravity.CENTER);// www .  ja v a 2  s  .c  om
    ;
    text.setTextColor(getResources().getColor(R.color.color_off_white));
    toast.show();
}