当前位置: 首页>>代码示例>>Java>>正文


Java Toast.LENGTH_LONG属性代码示例

本文整理汇总了Java中android.widget.Toast.LENGTH_LONG属性的典型用法代码示例。如果您正苦于以下问题:Java Toast.LENGTH_LONG属性的具体用法?Java Toast.LENGTH_LONG怎么用?Java Toast.LENGTH_LONG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.widget.Toast的用法示例。


在下文中一共展示了Toast.LENGTH_LONG属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showToast

/**
 * {@link #tintDrawable(Drawable, ColorStateList)}
 * @param content content to show
 * @param longTime short or long
 * @param context context
 * @param textColor toast text color
 * @param toastBackgroundColor toast background color
 */
public static void showToast(@NonNull Context context, String content, boolean longTime,@ColorInt int toastBackgroundColor ,@ColorInt
        int textColor) {
    int type = longTime ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(context, content, type);
    View toastView = toast.getView();
    TextView textView = (TextView) toastView.findViewById(android.R.id.message);
    if (toastBackgroundColor != 0){
        Drawable toastBackgroundDrawable = tintDrawable(toastView.getBackground(), ColorStateList.valueOf(toastBackgroundColor));
        toastView.setBackgroundDrawable(toastBackgroundDrawable);
    }
    if (textColor!=0){
        textView.setTextColor(textColor);
    }
    toast.setView(toastView);
    toast.setText(content);
    toast.show();
}
 
开发者ID:didikee,项目名称:CommonDependence,代码行数:25,代码来源:UIToast.java

示例2: showToast

/**
 * {@link layout/transient_notification.xml}
 * @param content content to show
 * @param longTime short or long
 * @param context context
 * @param textColor toast text color
 * @param toastBackgroundColor toast background color
 */
public static void showToast(@NonNull Context context, String content, boolean longTime, @ColorInt
        int textColor,@ColorInt int toastBackgroundColor) {
    int type = longTime ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(context, content, type);
    ViewGroup toastView = (ViewGroup) LayoutInflater.from(context).inflate(R.layout
            .layout_toast, null, false);
    if (toastBackgroundColor != 0) {
        toastView.setBackgroundDrawable(getToastBackground(context, toastBackgroundColor));
    }
    TextView textView = (TextView) toastView.findViewById(android.R.id.message);
    // 内部已经作非空判断了
    if (textColor!=0){
        textView.setTextColor(textColor);
    }
    Typeface typeface = Typeface.create("sans-serif-condensed", Typeface.NORMAL);
    textView.setTypeface(typeface);
    toast.setView(toastView);
    toast.setText(content);
    toast.show();
}
 
开发者ID:didikee,项目名称:CommonDependence,代码行数:28,代码来源:UIToast2.java

示例3: getStorageDir

public File getStorageDir(Context context, String directoryName) {
    File file =
            new File(Environment.getExternalStoragePublicDirectory("/"), directoryName);

    System.out.println("canRead " + Environment.getExternalStorageDirectory().canRead());
    System.out.println("canWrite " + Environment.getExternalStorageDirectory().canWrite());

    boolean ok = file.mkdirs(); //create folders where write files
    if (!ok) {
        CharSequence text = "Failed to create dir " + file;
        int duration = Toast.LENGTH_LONG;

        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
    }
    return file;
}
 
开发者ID:JumpMind,项目名称:symmetric-android-client-demo,代码行数:17,代码来源:MainActivity.java

示例4: show

/**
 * Show a toast.
 *
 * @param text         The text to show.
 * @param durationLong Whether the toast show for a long period of time?
 * @param mode         The display mode to use.  Either {@link Mode#NORMAL} or {@link Mode#REPLACEABLE}
 */
public static void show(CharSequence text, boolean durationLong, Mode mode) {
    final int duration = durationLong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;

    if (mode != Mode.REPLACEABLE) {
        Toast.makeText(sContext, text, duration).show();
        return;
    }

    if (sToast == null || sDuration != duration) {
        sDuration = duration;
        sToast = Toast.makeText(sContext, text, duration);
    } else {
        try {
            sToast.setText(text);
        } catch (RuntimeException e) {
            sToast = Toast.makeText(sContext, text, duration);
        }
    }
    sToast.show();
}
 
开发者ID:GuJin,项目名称:ToastUtil,代码行数:27,代码来源:ToastUtil.java

示例5: run

public void run()
{
	String s = aFile.getName();
	setTitleBarText(aFile.getName());


	progressDlg.dismiss();
	int duration = Toast.LENGTH_LONG;
	Toast.makeText(TextEdit.this, getString(R.string.toast_save) + ": " + s, duration).show();


	setResultForActionGetContent();

	if(closeAfterSaveFlag)
	{
		finish();
	}

	messageDigest = getMessageDigest();
}
 
开发者ID:monolifed,项目名称:mininoteview,代码行数:20,代码来源:TextEdit.java

示例6: showToast

/**
 * show a toast using resource Globals.getId()
 *
 * @param context
 * @param resId
 * @param isLong
 */
public static void showToast(final Context context, final int resId, final boolean isLong) {
    if (isLong) {
        LENGTH = Toast.LENGTH_LONG;
    } else {
        LENGTH = Toast.LENGTH_SHORT;
    }
    showToast(context, context.getString(resId));
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:15,代码来源:ToastUtil.java

示例7: toast

@WXModuleAnno
public void toast(String param) {

  String message = "";
  int duration = Toast.LENGTH_SHORT;
  if (!TextUtils.isEmpty(param)) {
    try {
      param = URLDecoder.decode(param, "utf-8");
      JSONObject jsObj = new JSONObject(param);
      message = jsObj.optString(MESSAGE);
      duration = jsObj.optInt(DURATION);
    } catch (Exception e) {
      WXLogUtils.e("[WXModalUIModule] alert param parse error ", e);
    }
  }
  if (TextUtils.isEmpty(message)) {
    WXLogUtils.e("[WXModalUIModule] toast param parse is null ");
    return;
  }

  if (duration > 3) {
    duration = Toast.LENGTH_LONG;
  } else {
    duration = Toast.LENGTH_SHORT;
  }
  if(toast== null){
    toast =Toast.makeText(mWXSDKInstance.getContext(), message, duration);
  } else {
    toast.setDuration(duration);
    toast.setText(message);
  }
  toast.setGravity(Gravity.CENTER, 0, 0);
  toast.show();
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:34,代码来源:WXModalUIModule.java

示例8: toast

@JSMethod(uiThread = true)
public void toast(String param) {

  String message = "";
  int duration = Toast.LENGTH_SHORT;
  if (!TextUtils.isEmpty(param)) {
    try {
      param = URLDecoder.decode(param, "utf-8");
      JSONObject jsObj = JSON.parseObject(param);
      message = jsObj.getString(MESSAGE);
      duration = jsObj.getInteger(DURATION);
    } catch (Exception e) {
      WXLogUtils.e("[WXModalUIModule] alert param parse error ", e);
    }
  }
  if (TextUtils.isEmpty(message)) {
    WXLogUtils.e("[WXModalUIModule] toast param parse is null ");
    return;
  }

  if (duration > 3) {
    duration = Toast.LENGTH_LONG;
  } else {
    duration = Toast.LENGTH_SHORT;
  }
  if (toast == null) {
    toast = Toast.makeText(mWXSDKInstance.getContext(), message, duration);
  } else {
    toast.setDuration(duration);
    toast.setText(message);
  }
  toast.setGravity(Gravity.CENTER, 0, 0);
  toast.show();
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:34,代码来源:WXModalUIModule.java

示例9: notifyIfNotGranted

/**
 * Checks for permissions and notifies the user if they aren't granted
 **/
public static void notifyIfNotGranted(@NonNull Context context) {
    StringBuilder sb = new StringBuilder();
    int count = 0;
    for (String permission : PERMISSIONS) {
        if (!isGranted(context, permission)) {
            if (count > 0) {
                sb.append("\n");
            }
            String info = getPermissionInfo(context, permission);
            sb.append(info);
            sb.append(";");
            count++;
        }
    }

    if (count > 0) {
        int duration;
        String message = context.getString(R.string.app_name) + " ";
        if (count == 1) {
            duration = Toast.LENGTH_SHORT;
            message += context.getString(R.string.needs_permission) + ":\n" + sb.toString();
        } else {
            duration = Toast.LENGTH_LONG;
            message += context.getString(R.string.needs_permissions) + ":\n" + sb.toString();
        }
        Utils.showToast(context, message, duration);
    }
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:31,代码来源:Permissions.java

示例10: toastText

void toastText(String text, Boolean isLong)
{
	int i;
	if (isLong)
		i = Toast.LENGTH_LONG;
	else
		i = Toast.LENGTH_SHORT;
	Toast.makeText(getApplicationContext(), text, i).show();
}
 
开发者ID:nijigenirubasho,项目名称:mobiletailchanger,代码行数:9,代码来源:MainActivity.java

示例11: setDuration

@Override
public IBuilder setDuration(long durationMillis) {
    if (durationMillis < 0) {
        mBuilderDurationMillis = 0;
    }
    if (durationMillis == Toast.LENGTH_SHORT) {
        mBuilderDurationMillis = 2000;
    } else if (durationMillis == Toast.LENGTH_LONG) {
        mBuilderDurationMillis = 3500;
    } else {
        mBuilderDurationMillis = durationMillis;
    }
    return this;
}
 
开发者ID:gslovemy,项目名称:ToastCompat,代码行数:14,代码来源:CustomToast.java

示例12: showToast

public static void showToast(Context context, String msg) {
    if (msg == null || "".equals(msg)) {
        return;
    }
    int duration = msg.length() > 15 ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
    if (mToast == null) {
        mToast = Toast.makeText(context, msg, duration);
    } else {
        mToast.setText(msg);
        mToast.setDuration(duration);
    }
    mToast.show();
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:13,代码来源:ToastUtil.java

示例13: show

public static void show(Context context, String content, int gravity, int duration) {
    long current = System.currentTimeMillis();
    //if (current < nextTimeMillis) return;
    if (mToast == null) init(context.getApplicationContext());
    mToast.setText(content);
    mToast.setDuration(duration);
    mToast.setGravity(gravity, 0, yOffset);
    nextTimeMillis = current + (duration == Toast.LENGTH_LONG ? 3500 : 2000);
    mToast.show();
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:10,代码来源:SimplexToast.java

示例14: showMessage

/**
 * Show message to user if needed
 * @param message
 */
protected void showMessage(String message) {
    Context context = getApplicationContext();
    int duration = Toast.LENGTH_LONG;

    Toast toast = Toast.makeText(context, message, duration);
    toast.show();
}
 
开发者ID:intari,项目名称:AndroidToolbox,代码行数:11,代码来源:GNSSLocationService.java

示例15: toaster

public void toaster(String message, @NonNull String duration){
    int toastDuration;
    if (duration.equals("s")){toastDuration = Toast.LENGTH_SHORT;}
    else{toastDuration = Toast.LENGTH_LONG;}
    Toast.makeText(getApplicationContext(),message,toastDuration).show();
}
 
开发者ID:amir511,项目名称:My-Sheep,代码行数:6,代码来源:AddKid.java


注:本文中的android.widget.Toast.LENGTH_LONG属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。