當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。