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


Java Toast.LENGTH_SHORT属性代码示例

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


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

示例1: onPostExecute

protected void onPostExecute(RetornoLogin result) {
    Context context = getApplicationContext();
    String texto = "";
    if( result.getCodigo() == RetornoLogin.OK){
        // Starting MainActivity
        Intent i = new Intent(getApplicationContext(), EnviarFotoActivity.class);

        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        // Add new Flag to start new Activity
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(i);

        finish();
    }else{
        texto = "Falha ao autenticar";
    }
    CharSequence text = texto;
    int duration = Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(context, text, duration);
    toast.show();
}
 
开发者ID:chacaldev,项目名称:provadevida,代码行数:22,代码来源:MainActivity.java

示例2: showToast

public static void showToast(String s) {
    if (toast == null) {
        toast = Toast.makeText(sContext, s, Toast.LENGTH_SHORT);
        toast.show();
        oneTime = System.currentTimeMillis();
    } else {
        twoTime = System.currentTimeMillis();
        if (s.equals(oldMsg)) {
            if (twoTime - oneTime > Toast.LENGTH_SHORT) {
                toast.show();
            }
        } else {
            oldMsg = s;
            toast.setText(s);
            toast.show();
        }
        oneTime = twoTime;
    }
}
 
开发者ID:lai233333,项目名称:MyDemo,代码行数:19,代码来源:ToastUtil.java

示例3: onClick

public void onClick(View v) {
    Intent intent = new Intent();
    switch (v.getId()) {
        case R.id.Accessibility:
            Context context = getApplicationContext();
            CharSequence text = "請激活 MiHomePlus 無障礙設定";
            int duration = Toast.LENGTH_SHORT;
            Toast.makeText(context, text, duration).show();

            //打开系统无障碍设置界面
            Intent accessibleIntent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
            startActivity(accessibleIntent);
            break;
        case R.id.AppSetting:
            intent.setClass(MainActivity.this, AppSetting.class);
            startActivity(intent);
            break;
        case R.id.Help:
            intent.setClass(MainActivity.this, Help.class);
            startActivity(intent);
            break;
        default:
            break;
    }
}
 
开发者ID:qoli,项目名称:MiHomePlus,代码行数:25,代码来源:MainActivity.java

示例4: showToast

/**
 * 吐出一个显示时间较短的提示
 *
 * @param context 上下文
 * @param s       文本内容
 */
public static void showToast(Context context, String s) {
    if (toast == null) {
        toast = Toast.makeText(context, s, Toast.LENGTH_SHORT);
        toast.show();
        oneTime = System.currentTimeMillis();
    } else {
        twoTime = System.currentTimeMillis();
        if (s.equals(oldMsg)) {
            if (twoTime - oneTime > Toast.LENGTH_SHORT) {
                toast.show();
            }
        } else {
            oldMsg = s;
            toast.setText(s);
            toast.show();
        }
    }
    oneTime = twoTime;
}
 
开发者ID:Catslovetoplaygames,项目名称:MVP,代码行数:25,代码来源:ToastUtils.java

示例5: 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

示例6: initData

private void initData() {
    mCardView.setRadius(SuperToastUtils.dip2px(mContext, 20));
    mCardView.setCardElevation(2);
    mCardView.setCardBackgroundColor(SuperToastUtils.NORMAL_COLOR);
    mTextView.setTextColor(SuperToastUtils.DEFAULT_TEXT_COLOR);

    mDuration = Toast.LENGTH_SHORT;
    isOutDuration = false;
    isSetRadis = false;

    mToast = new Toast(mContext);
    mToast.setView(mParentView);
}
 
开发者ID:zzyandzzy,项目名称:SuperToast,代码行数:13,代码来源:SuperToast.java

示例7: showToast

public static void showToast(Context context, String s, int duration) {
	if (context == null){
		return;
	}
	if (context != null && context instanceof Activity) {
        if(((Activity) context).isFinishing()) {
            return;
        }
	}
	if(!TextUtils.isEmpty(s) && !"".equals(s.trim())){
		if (toast == null) {
			toast = Toast.makeText(context, s, Toast.LENGTH_SHORT);
			toast.show();
			oneTime = System.currentTimeMillis();
		} else {
			if (s == null) s="null";
			twoTime = System.currentTimeMillis();
			if (s.equals(oldMsg)) {
				if (twoTime - oneTime > Toast.LENGTH_SHORT) {
					toast.show();
				}
			} else {
				oldMsg = s;
				toast.setText(s);
				toast.show();
			}
		}
		oneTime = twoTime;
	}
}
 
开发者ID:zmobs,项目名称:DoChart,代码行数:30,代码来源:DoToast.java

示例8: initialize

private void initialize(Context ctx, Position pos) {
    inflator = LayoutInflater.from(ctx);
    context = ctx;
    iconDownloadTasks = new ArrayList<IconDownloadTask>();
    ContentDirectoryBrowseResult result = UpnpClient.getInstance(null)
            .browseSync(pos);
    if (result == null)
        return;
    DIDLContent a = result.getResult();
    if (a != null) {
        objects = new LinkedList<DIDLObject>();
        // Add all children in two steps to get containers first
        objects.addAll(a.getContainers());
        objects.addAll(a.getItems());
    } else {
        // If result is null it may be an empty result
        // only in case of an UpnpFailure in the result it is really an
        // failure

        if (result.getUpnpFailure() != null) {
            String text = ctx.getString(R.string.error_upnp_generic);
            int duration = Toast.LENGTH_SHORT;
            text = ctx.getString(R.string.error_upnp_specific) + " "
                    + result.getUpnpFailure();
            Log.e("ResolveError", text + "(" + pos.getObjectId() + ")");
            Toast toast = Toast.makeText(ctx, text, duration);
            toast.show();
        } else {
            objects = new LinkedList<DIDLObject>();
        }

    }
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:33,代码来源:BrowseItemAdapter.java

示例9: 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

示例10: 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

示例11: saveSettings

public static boolean saveSettings()	{
	//Save preferences
	SharedPreferences settings = AppSmartMath.getContext().getSharedPreferences(SETTINGS, 0);
	if (settings != null) {
		/*
		 * Note: we cannot write like
		 * settings.edit().putInt(BITS_OF_PRECISION, nBitsofPrecision);
		 * settings.edit().putInt(NUMBER_OF_RECORDS, nNumberofRecords);
		 * settings.edit().commit();
		 * because settings.edit() returns different editor each time.
		 */
		settings.edit().putInt(BITS_OF_PRECISION, msnBitsofPrecision)
					.putInt(BIG_SMALL_THRESH, msnBigSmallThresh)
					.putInt(NUMBER_OF_RECORDS, msnNumberofRecords)
					.putFloat(SMC_PLOT_VAR_FROM, msfSmCPlotVarFrom)
					.putFloat(SMC_PLOT_VAR_TO, msfSmCPlotVarTo)
					.putBoolean(ENABLE_BUTTON_PRESS_VIBRATION, msbEnableBtnPressVibration)
					.putString(AndroidStorageOptions.SELECTED_STORAGE_PATH, AndroidStorageOptions.getSelectedStoragePath())
					.commit();
		
		IOLib.msstrWorkingDir = MFPFileManagerActivity.getAppFolderFullPath();	// set the initial working directory.		

		CharSequence text = AppSmartMath.getContext().getString(R.string.settings_saved);
		int duration = Toast.LENGTH_SHORT;

		Toast toast = Toast.makeText(AppSmartMath.getContext(), text, duration);
		toast.show();
		return true;
	}
	return false;
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:31,代码来源:ActivitySettings.java

示例12: getDuration

public
@Duration
int getDuration() {
    if (duration != 0)
        return duration;
    return Toast.LENGTH_SHORT;
}
 
开发者ID:Poizi,项目名称:PoiziToast,代码行数:7,代码来源:PoiziToastOptionModel.java

示例13: showToast

private void showToast(String message){
    Context context = getApplicationContext();
    CharSequence text = message;
    int duration = Toast.LENGTH_SHORT;

    Toast toast = Toast.makeText(context, text, duration);
    toast.show();
}
 
开发者ID:bencikpeter,项目名称:3DPrintingProtocols,代码行数:8,代码来源:MainActivity.java

示例14: 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

示例15: linkError

private void linkError(int errorCode) {

        // This is called if some error happened
        // Here we set up the first vars
        Context context = getApplicationContext();
        int duration = Toast.LENGTH_SHORT;
        Toast toast;


        // Whatever happened we want to return to the start Activity. If possible with
        // some information about what went wrong. Therefore we can already set the Intent up
        Intent intent = new Intent(context, MainActivity.class);
        intent.putExtra(EXTRA_MESSAGE, originalUrl);
        intent.putExtra(ERROR_BOOL, true);

        // If we can determine the type of the error we add an Error message:
        switch(errorCode){
            case 2:
                toast = Toast.makeText(context,  getString(R.string.error_system_url), duration);
                intent.putExtra(ERROR_MESSAGE, getString(R.string.error_system_url));
                break;
            default:
                toast = Toast.makeText(context,  getString(R.string.error_generic_url), duration);
                intent.putExtra(ERROR_MESSAGE, getString(R.string.error_generic_url));
        }


        if(!foreignIntent) {
            // And start the MainActivity (if the Intent didn't come through a Share)
            toast = Toast.makeText(context,  getString(R.string.error_toast), duration);
            startActivity(intent);
        }

        // We show the error toast
        toast.show();

        // At the same time we finish() since the data in this Activity shall be purged
        // (The visible / gone / hidden settings need to be reset)
        finish();

    }
 
开发者ID:michaelachmann,项目名称:LnkShortener,代码行数:41,代码来源:DisplayShortenedUrlActivity.java


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