Exemple #1
0
 @Override
 public void onClick(View v) {
   if (v == close) {
     overridePendingTransition(R.anim.pull_in_from_left, R.anim.hold);
     finish();
   }
   if (v == login) {
     name = uName.getText().toString();
     pwd = pass.getText().toString();
     db.open();
     Cursor mCursor = db.getAllRecords();
     mCursor.moveToFirst();
     rName = mCursor.getString(1);
     rPass = mCursor.getString(2);
     db.close();
     if (rPass.equals(pwd)) {
       LayoutInflater mInflater = getLayoutInflater();
       View layout =
           mInflater.inflate(R.layout.toast2, (ViewGroup) findViewById(R.id.custom_toast2));
       TextView text = (TextView) layout.findViewById(R.id.toast_text2);
       text.setText("Login in progress!!");
       toast = new Toast(getApplicationContext());
       toast.setDuration(Toast.LENGTH_LONG);
       toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
       toast.setView(layout);
       toast.show();
       intent = new Intent("com.muneebahmad.moneyman.HOME");
       overridePendingTransition(R.anim.pull_in_from_left, R.anim.hold);
       startActivity(intent);
       finish();
     } else {
       LayoutInflater mInflater = getLayoutInflater();
       View layout =
           mInflater.inflate(R.layout.toast2, (ViewGroup) findViewById(R.id.custom_toast2));
       TextView text = (TextView) layout.findViewById(R.id.toast_text2);
       text.setText("for user: [" + rName + "] Please Supply valid password!");
       toast = new Toast(getApplicationContext());
       toast.setDuration(Toast.LENGTH_LONG);
       toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
       toast.setView(layout);
       toast.show();
     }
   }
   if (v == forget) {
     intent = new Intent("com.muneebahmad.moneyman.FORGET");
     startActivity(intent);
     finish();
   }
 } // end onClick()
  // 录音时间太短时Toast显示
  void showWarnToast(String toastText) {
    Toast toast = new Toast(ChatActivity.this);
    LinearLayout linearLayout = new LinearLayout(ChatActivity.this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setPadding(20, 20, 20, 20);

    // 定义一个ImageView
    ImageView imageView = new ImageView(ChatActivity.this);
    imageView.setImageResource(R.mipmap.voice_to_short); // 图标

    TextView mTv = new TextView(ChatActivity.this);
    mTv.setText(toastText);
    mTv.setTextSize(14);
    mTv.setTextColor(Color.WHITE); // 字体颜色

    // 将ImageView和ToastView合并到Layout中
    linearLayout.addView(imageView);
    linearLayout.addView(mTv);
    linearLayout.setGravity(Gravity.CENTER); // 内容居中
    linearLayout.setBackgroundResource(R.mipmap.record_bg); // 设置自定义toast的背景

    toast.setView(linearLayout);
    toast.setGravity(Gravity.CENTER, 0, 0); // 起点位置为中间
    toast.show();
  }
  private void showToast(String mensaje, int numImage) {
    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);

    switch (numImage) {
      case 0:
        image.setImageResource(R.drawable.ic_ok);
        break;
      case 1:
        image.setImageResource(R.drawable.ic_error);
        break;
      default:
        image.setImageResource(R.drawable.ic_launcher);
        break;
    }

    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText(mensaje);

    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
    toast.setDuration(Toast.LENGTH_SHORT);
    toast.setView(layout);
    toast.show();
  }
Exemple #4
0
  public static void makeText(Context context, String text, int duration) {
    getInstance(context);
    getToast(duration);
    if (mInstance.layout == null || mInstance.tv == null) {
      LinearLayout container = new LinearLayout(mContext);
      LinearLayout.LayoutParams rootParams =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      container.setLayoutParams(rootParams);
      container.setBackgroundColor(context.getResources().getColor(android.R.color.transparent));
      container.setGravity(Gravity.CENTER);

      mInstance.tv = new TextView(mContext);
      LinearLayout.LayoutParams tvParams =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      mInstance.tv.setLayoutParams(tvParams);
      mInstance.tv.setPadding(dp2px(10), dp2px(2), dp2px(10), dp2px(2));
      mInstance.tv.setGravity(Gravity.CENTER);
      mInstance.tv.setTextColor(DEFAULT_TEXT_COLOR);
      mInstance.tv.setMaxLines(2);
      mInstance.tv.setEllipsize(TextUtils.TruncateAt.END);
      mInstance.tv.setTextSize(DEFAULT_TEXT_SIZE);
      mInstance.tv.setBackgroundResource(DEFAULT_BG_TEXT);

      container.addView(mInstance.tv);
      mInstance.layout = container;
      mToast.setView(mInstance.layout);
    }
    mInstance.tv.setText(text);
    mToast.show();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    if (getDeviceDefaultOrientation() == Configuration.ORIENTATION_PORTRAIT) {
      setContentView(R.layout.activity_login_port);
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {
      setContentView(R.layout.activity_login_land);
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

    userid = (EditText) findViewById(R.id.userid);
    pass = (EditText) findViewById(R.id.pass);
    loading = (ProgressBar) findViewById(R.id.login_loading);
    login = (Button) findViewById(R.id.login);
    logtask = null;

    LayoutInflater inflater = getLayoutInflater();
    layout = inflater.inflate(R.layout.info, (ViewGroup) findViewById(R.id.toast_layout_root));
    information = (TextView) layout.findViewById(R.id.information);

    toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(Toast.LENGTH_SHORT);
    toast.setView(layout);
  }
  private void initializeWidgets(View view) {
    imgViewCircle =
        (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_circle);

    imgViewsArray[0] =
        (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option1_rounded);
    imgViewsArray[1] =
        (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option2_rounded);
    imgViewsArray[2] =
        (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option3_rounded);
    imgViewsArray[3] =
        (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option4_rounded);
    for (RoundedImageView roundedImageView : imgViewsArray) {
      roundedImageView.setCornerRadius((float) 20);
    }

    txtViewsArray[0] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option1);
    txtViewsArray[1] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option2);
    txtViewsArray[2] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option3);
    txtViewsArray[3] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option4);

    View toastView = getActivity().getLayoutInflater().inflate(R.layout.toast_error, null);
    errorToast = new Toast(getActivity().getApplicationContext());
    errorToast.setGravity(Gravity.BOTTOM, 0, 0);
    errorToast.setView(toastView);
  }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    String listItemName1 = Biography[info.position - 1];
    ListView wirdlist = (ListView) findViewById(R.id.biolist);
    LayoutInflater mInflater = getLayoutInflater();
    final View mLayout =
        mInflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root));
    final TextView mText = (TextView) mLayout.findViewById(R.id.toast_text);
    Toast mToast = new Toast(getApplicationContext());
    mToast.setDuration(Toast.LENGTH_SHORT);
    mToast.setView(mLayout);

    if (item.getItemId() == 0) {

      int menuItemIndex = item.getItemId();
      String[] menuItems = getResources().getStringArray(R.array.menu2);
      String menuItemName = menuItems[menuItemIndex];

      ClipData clip = ClipData.newPlainText("simple text", listItemName1);
      clipboard.setPrimaryClip(clip);

      mText.setText("Text Copied");
      mToast.show();
    }

    return true;
  }
 /**
  * 展示一个粉色的Toast
  *
  * @param message
  */
 public void toast(String message) {
   View toastRoot = LayoutInflater.from(context).inflate(R.layout.toast, null);
   Toast toast = new Toast(context);
   toast.setView(toastRoot);
   TextView tv = (TextView) toastRoot.findViewById(R.id.pink_toast_notice);
   tv.setText(message);
   toast.show();
 }
 /**
  * Show custom toast.
  *
  * @param context the context
  * @param view the view
  * @param Duration the duration e.g <code>Toast.LENGTH_SHORT</code> , <code>Toast.LENGTH_LONG
  *     </code>
  * @param gravity the gravity e.g <code>GRAVITY.BOTTOM</code> , <code>GRAVITY.CENTER_VERTICAL
  *     </code> , etc
  * @param xoffset the x offset
  * @param yoffset the y offset
  */
 public static void showCustomToast(
     Context context, View view, int Duration, int gravity, int xoffset, int yoffset) {
   Toast newCustomToast = new Toast(context);
   newCustomToast.setView(view);
   newCustomToast.setDuration(Duration);
   newCustomToast.setGravity(gravity, xoffset, yoffset);
   newCustomToast.show();
 }
 public void viewImage(View v) {
   Toast t = new Toast(this);
   ImageView imageview = new ImageView(this); // 类似,TextView等等
   imageview.setImageResource(R.drawable.apk);
   t.setView(imageview);
   t.setGravity(Gravity.TOP, 0, 0);
   t.setDuration(Toast.LENGTH_LONG);
   t.show();
 }
 /** 显示自定义Toast提示(来自String) * */
 protected void showCustomToast(String text) {
   View toastRoot = LayoutInflater.from(BaseActivity.this).inflate(R.layout.common_toast, null);
   ((HandyTextView) toastRoot.findViewById(R.id.toast_text)).setText(text);
   Toast toast = new Toast(BaseActivity.this);
   toast.setGravity(Gravity.CENTER, 0, 0);
   toast.setDuration(Toast.LENGTH_SHORT);
   toast.setView(toastRoot);
   toast.show();
 }
 public static Toast makeText(Context context, CharSequence msg, int duration) {
   if (((OsmandApplication) context.getApplicationContext()).accessibilityExtensions()) {
     final Toast toast = new AccessibleToast(context);
     toast.setView(TextMessage.makeView(context, msg, R.layout.notification));
     toast.setDuration(duration);
     return toast;
   }
   return Toast.makeText(context, msg, duration);
 }
 private void showRepeatedEggToast() {
   LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
   View toastView = inflater.inflate(R.layout.repeatedegg, null);
   Toast repeatedEggToast = new Toast(this);
   repeatedEggToast.setGravity(Gravity.CENTER, 0, 0);
   repeatedEggToast.setView(toastView);
   repeatedEggToast.setDuration(500);
   repeatedEggToast.show();
 }
  /** Creates and displays a custom information toast with custom message that it receives */
  private void displayInfoToast(String messageToDisplay) {
    Toast infoToast = new Toast(getApplicationContext());

    View toastView = inflater.inflate(R.layout.toast_info, null);
    infoToast.setView(toastView);
    ((TextView) toastView.findViewById(R.id.display_text)).setText(messageToDisplay);

    infoToast.show();
  }
 public static void toast(Context context, String textString) {
   View view = LayoutInflater.from(context).inflate(R.layout.toast, null);
   TextView textView = (TextView) view.findViewById(R.id.toast_text);
   textView.setText(textString);
   Toast toast = new Toast(context); // 创建一个toast
   toast.setGravity(Gravity.CENTER, 0, 0);
   toast.setDuration(Toast.LENGTH_LONG);
   toast.setView(view); // 为toast设置一个view
   toast.show();
 }
 private void MensajeIconToast(int layout, int duration) {
   LayoutInflater inf = getLayoutInflater();
   View layoutView = inf.inflate(layout, null);
   Toast t = new Toast(getApplicationContext());
   t.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
   t.setDuration(Toast.LENGTH_LONG);
   t.setDuration(duration);
   t.setView(layoutView);
   t.show();
 }
 /**
  * 显示录音时间过短的Toast @Title: showShortToast
  *
  * @return void
  * @throws
  */
 private Toast showShortToast() {
   if (toast == null) {
     toast = new Toast(this);
   }
   View view = LayoutInflater.from(this).inflate(R.layout.lay_chat_voice_short, null);
   toast.setView(view);
   toast.setGravity(Gravity.CENTER, 0, 0);
   toast.setDuration(50);
   return toast;
 }
  /**
   * Display a system Toast using a custom ui view.
   *
   * @param viewResId the view res id
   * @param duration the duration
   * @param gravity the gravity
   */
  public static void showCustomToast(int viewResId, int duration, int gravity) {
    View layout = getLayoutInflater().inflate(viewResId, null);

    Toast toast = new Toast(mContext.getApplicationContext());

    toast.setGravity(gravity, 0, 0);
    toast.setDuration(duration);
    toast.setView(layout);
    toast.show();
  }
Exemple #19
0
 public static void showErrorToast(String error, int duration, Context context) {
   LayoutInflater inflater =
       (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   Toast t = new Toast(context);
   t.setDuration(duration);
   View v = inflater.inflate(R.layout.error_toast, null);
   TextView errorMessage = (TextView) v.findViewById(R.id.errorMessage);
   errorMessage.setText(error);
   t.setView(v);
   t.show();
 }
Exemple #20
0
 private void createToast(String message) {
   LayoutInflater inflater = getLayoutInflater();
   View layout =
       inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.toast_layout_root));
   TextView text = (TextView) layout.findViewById(R.id.text);
   text.setText(message);
   Toast toast = new Toast(getApplicationContext());
   toast.setDuration(Toast.LENGTH_SHORT);
   toast.setView(layout);
   toast.show();
 }
 public void run() {
   View layout = LayoutInflater.from(context).inflate(R.layout.zone_toast_layout, null);
   TextView text = (TextView) layout.findViewById(R.id.tvForToast);
   text.setText(context.getString(resIdLast));
   toastLast = new Toast(context);
   toastLast.setGravity(Gravity.CENTER, 0, 0);
   toastLast.setDuration(Toast.LENGTH_LONG);
   toastLast.setView(layout);
   toastLast.show();
   showTimeLast = System.currentTimeMillis();
 }
 public void showCustomToast(String toast) {
   LayoutInflater inflater = LayoutInflater.from(context);
   View view = inflater.inflate(R.layout.toast_item, (ViewGroup) findViewById(R.id.toast_item));
   TextView text = (TextView) view.findViewById(R.id.toast_text);
   text.setText(toast);
   Toast tempToast = new Toast(context);
   tempToast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER, 0, 0);
   tempToast.setDuration(Toast.LENGTH_SHORT);
   tempToast.setView(view);
   tempToast.show();
 }
 public void show(float progress) {
   if (t == null) {
     t = new Toast(context);
     View layout = LayoutInflater.from(context).inflate(R.layout.vv, null);
     tv = (VolumnView) layout.findViewById(R.id.volumnView);
     t.setView(layout);
     t.setGravity(Gravity.BOTTOM, 0, 100);
     t.setDuration(Toast.LENGTH_SHORT);
   }
   tv.setProgress(progress);
   t.show();
 }
Exemple #24
0
  public static void showMyToast(Context context, int icon, String text) {
    Toast toast = new Toast(context);
    View view = View.inflate(context, R.layout.mytoast, null);
    TextView tv_toast = (TextView) view.findViewById(R.id.tv_toast);
    ImageView iv_toast = (ImageView) view.findViewById(R.id.iv_toast);
    tv_toast.setText(text);
    iv_toast.setImageResource(icon);

    toast.setView(view);
    toast.setDuration(Toast.LENGTH_SHORT);
    toast.show();
  }
Exemple #25
0
  private static synchronized void createToast(Context context, int duration) {
    if (null == mToast) {
      View toastRoot = View.inflate(context, R.layout.toast, null);
      toastMsg = (TextView) toastRoot.findViewById(R.id.message);

      mToast = new Toast(context);
      mToast.setView(toastRoot);
    }

    mToast.setGravity(Gravity.CENTER, 0, 0);
    mToast.setDuration(duration);
  }
  private void showOverlay() {
    // Generate a toast view with a special layout that will position itself right
    // on top of this view's interesting widgets.  Sneaky huh?
    SecureViewOverlay overlay =
        (SecureViewOverlay) getLayoutInflater().inflate(R.layout.secure_view_overlay, null);
    overlay.setActivityToSpoof(this);

    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.FILL, 0, 0);
    toast.setView(overlay);
    toast.show();
  }
 public ToastView(Context context, int text) {
   LayoutInflater inflater = LayoutInflater.from(context);
   View view = inflater.inflate(R.layout.taost_view, null);
   TextView t = (TextView) view.findViewById(R.id.toast_text);
   t.setText(text);
   if (toast != null) {
     toast.cancel();
   }
   toast = new Toast(context);
   toast.setDuration(Toast.LENGTH_SHORT);
   toast.setView(view);
 }
  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);

    final Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(duration);
    toast.setView(layout);
    toast.show();
  }
 private Toast createCongratsImage() {
   LayoutInflater inflater = getLayoutInflater();
   View layout =
       inflater.inflate(
           R.layout.congrats_image, (ViewGroup) findViewById(R.id.custom_toast_layout_id));
   ImageView image = (ImageView) layout.findViewById(R.id.imageCongrats);
   image.setImageResource(R.drawable.congrat);
   Toast toast = new Toast(getApplicationContext());
   toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
   toast.setDuration(Toast.LENGTH_LONG);
   toast.setView(layout);
   return toast;
 }
Exemple #30
0
 private void midToast(String str, int showTime) {
   LayoutInflater inflater = getLayoutInflater();
   View view =
       inflater.inflate(R.layout.view_toast_custom, (ViewGroup) findViewById(R.id.lly_toast));
   ImageView img_logo = (ImageView) view.findViewById(R.id.img_logo);
   TextView tv_msg = (TextView) view.findViewById(R.id.tv_msg);
   tv_msg.setText(str);
   Toast toast = new Toast(mContext);
   toast.setGravity(Gravity.CENTER, 0, 0);
   toast.setDuration(Toast.LENGTH_LONG);
   toast.setView(view);
   toast.show();
 }