Example usage for android.widget Toast Toast

List of usage examples for android.widget Toast Toast

Introduction

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

Prototype

public Toast(Context context) 

Source Link

Document

Construct an empty Toast object.

Usage

From source file:xj.property.activity.HXBaseActivity.HXBaseActivity.java

/**
 * Toast ,, ?.//from   w ww . j a va2s  .  co  m
 *
 * @param showT   
 * @param gravity ?
 */
protected void showCommonToast(String showT, int gravity) {

    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.common_welfare_toast_lay, null);
    TextView title = (TextView) layout.findViewById(R.id.toast_title_tv);
    title.setText(showT);
    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(gravity, 0, 0);
    toast.setDuration(Toast.LENGTH_LONG);
    toast.setView(layout);
    toast.show();
}

From source file:org.nla.tarotdroid.lib.ui.TabGameSetActivity.java

/**
 * Starts the whole Facebook post process.
 * //from  w  ww . j  av  a 2  s. c  om
 * @param session
 */
private void launchPostProcess(final Session session) {

    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toast_layout_root));

    ImageView image = (ImageView) layout.findViewById(R.id.image);
    image.setImageResource(R.drawable.icon_facebook_released);
    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText(this.getString(R.string.msgFacebookNotificationInProgress));

    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
    toast.setDuration(Toast.LENGTH_LONG);
    toast.setView(layout);
    toast.show();

    Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {

        @Override
        public void onCompleted(GraphUser user, Response response) {
            if (session == Session.getActiveSession()) {
                if (user != null) {
                    int notificationId = FacebookHelper.showNotificationStartProgress(TabGameSetActivity.this);
                    AppContext.getApplication().getNotificationIds()
                            .put(TabGameSetActivity.this.gameSet.getUuid(), notificationId);

                    AppContext.getApplication().setLoggedFacebookUser(user);
                    UpSyncGameSetTask task = new UpSyncGameSetTask(TabGameSetActivity.this, progressDialog);
                    task.setCallback(TabGameSetActivity.this.upSyncCallback);
                    task.execute(TabGameSetActivity.this.gameSet);
                }
            }
            if (response.getError() != null) {
                AuditHelper.auditErrorAsString(ErrorTypes.facebookNewMeRequestFailed,
                        response.getError().toString(), TabGameSetActivity.this);
            }
        }
    });
    request.executeAsync();
}

From source file:com.wewow.BaseActivity.java

private void showCacheClearedToast() {

    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.clear_cache_toast_view, null);

    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(Toast.LENGTH_SHORT);
    toast.setView(layout);//from  w w  w  .j  a v a  2 s .  c o  m
    toast.show();
}

From source file:com.netcompss.ffmpeg4android_client.BaseVideo.java

public void toastsettext(String string1) {
    LayoutInflater inflater = ((Activity) context).getLayoutInflater();
    View layout = inflater.inflate(R.layout.toast_activity,
            (ViewGroup) ((Activity) context).findViewById(R.id.toast_rl));
    TextView txt = (TextView) layout.findViewById(R.id.toast_txt);
    txt.setText(string1);/*from   ww  w . ja  v  a  2s .  c  om*/
    Toast tst = new Toast(context);
    tst.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
    tst.setDuration(Toast.LENGTH_SHORT);
    tst.setView(layout);
    tst.show();
}

From source file:co.taqat.call.CallActivity.java

public void displayCustomToast(final String message, final int duration) {
    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot));

    TextView toastText = (TextView) layout.findViewById(R.id.toastMessage);
    toastText.setText(message);//from  w  w  w .  j  a v  a  2  s .com

    final Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(duration);
    toast.setView(layout);
    toast.show();
}

From source file:com.ezac.gliderlogs.FlightOverviewActivity.java

private void makeToast(String msg, int mode) {

    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root));

    ImageView image = (ImageView) layout.findViewById(R.id.image);
    image.setImageResource(R.drawable.ic_launcher);
    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText(msg);// w w  w . j av a  2s.c o  m

    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
    toast.setDuration(Toast.LENGTH_LONG);
    toast.setView(layout);
    if (mode == 1) {
        text.setTextColor(Color.WHITE);
        toast.getView().setBackgroundColor(Color.RED);
        toast.setDuration(Toast.LENGTH_LONG);
    }
    if (mode == 2) {
        text.setTextColor(Color.WHITE);
        toast.getView().setBackgroundColor(Color.GREEN);
    }
    toast.show();
}

From source file:com.juick.android.ThreadFragment.java

public void showThread(JuickMessage jmsg, boolean keepShow) {
    if (jmsg.getReplyTo() != 0) {
        JuickMessage reply = jmsg;/*w  w  w.  j a v a  2  s  . c  o m*/
        LinearLayout ll = new LinearLayout(getActivity());
        ll.setOrientation(LinearLayout.VERTICAL);
        ll.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
        int totalCount = 0;
        while (reply != null) {
            totalCount += reply.Text.length();
            if (totalCount > 500 || ll.getChildCount() > 10)
                break;
            JuickMessagesAdapter.ParsedMessage parsedMessage = JuickMessagesAdapter
                    .formatMessageText(getActivity(), reply, true);
            TextView child = new TextView(getActivity());
            ll.addView(child, 0);
            child.setText(parsedMessage.textContent);
            if (reply.getReplyTo() < 1)
                break;
            reply = findReply(getListView(), reply.getReplyTo());
        }
        if (ll.getChildCount() != 0) {
            int xy[] = new int[2];
            getListView().getLocationOnScreen(xy);
            int windowHeight = getActivity().getWindow().getWindowManager().getDefaultDisplay().getHeight();
            int listBottom = getListView().getHeight() + xy[1];
            int bottomSize = windowHeight - listBottom;
            ll.setPressed(true);
            MainActivity.restyleChildrenOrWidget(ll);
            if (!keepShow || shownThreadToast.getView().getParent() == null) { // new or already hidden
                shownThreadToast = new Toast(getActivity());
                shownThreadToast.setView(ll);
                shownThreadToast.setGravity(Gravity.BOTTOM | Gravity.LEFT, 0, bottomSize);
                shownThreadToast.setDuration(Toast.LENGTH_LONG);
            }
            shownThreadToast.show();
        }
    }
}

From source file:org.xingjitong.LinphoneActivity.java

public void displayCustomToast(final String message, final int duration) {
    mHandler.post(new Runnable() {
        @Override/*from w  ww .j a v a2  s.c o  m*/
        public void run() {
            LayoutInflater inflater = getLayoutInflater();
            View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot));

            TextView toastText = (TextView) layout.findViewById(R.id.toastMessage);
            toastText.setText(message);
            final Toast toast = new Toast(getApplicationContext());
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.setDuration(duration);
            toast.setView(layout);
            toast.show();
        }
    });
}

From source file:com.bookkos.bircle.CaptureActivity.java

private void customToast(String toast_text, int icon, boolean bool) {
    getLayoutInflater();/*  w  ww. j ava 2s.c om*/
    LayoutInflater inflater = getLayoutInflater();

    int resource = 0;

    if (bool == true) {
        resource = R.layout.success_toast;
    } else {
        resource = R.layout.failure_toast;
    }

    View layout = inflater.inflate(resource, null);
    ImageView image = (ImageView) layout.findViewById(R.id.image);
    image.setImageResource(icon);

    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText(Html.fromHtml(toast_text));

    final Toast toast = new Toast(this);

    layout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            toast.cancel();
        }
    });

    toast.setView(layout);
    toast.setGravity(Gravity.CENTER, 0, 0);
    if (modeFlag == true) {
        toast.setDuration(Toast.LENGTH_SHORT);
    } else {
        toast.setDuration(Toast.LENGTH_LONG);
    }
    toast.show();

    //      Toast.makeText(context, toast_text, Toast.LENGTH_SHORT).show();
}

From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java

private Toast createToastShort(String text) {
    Toast toast = new Toast(this);
    TextView tv = new TextView(this);
    tv.setText(text);/*from   w  ww .j  a  va 2 s  .  c  om*/
    tv.setTextColor(ContextCompat.getColor(this, R.color.colorAccent));
    tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, TOAST_TEXT_SIZE);
    //        int pixel = (int)mWindowDensity * 56;
    int toastMargin = getResources().getDimensionPixelSize(R.dimen.toast_margin_top_bottom);
    tv.setPadding(0, toastMargin, 0, toastMargin);
    toast.setView(tv);
    toast.setGravity(mToastPosition, 0, 0);
    toast.setDuration(Toast.LENGTH_SHORT);

    return toast;
}