當前位置: 首頁>>代碼示例>>Java>>正文


Java StringRes類代碼示例

本文整理匯總了Java中android.support.annotation.StringRes的典型用法代碼示例。如果您正苦於以下問題:Java StringRes類的具體用法?Java StringRes怎麽用?Java StringRes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StringRes類屬於android.support.annotation包,在下文中一共展示了StringRes類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: alert

import android.support.annotation.StringRes; //導入依賴的package包/類
/**
 * Show an alert dialog to the user
 * @param messageId String id to display inside the alert dialog
 * @param optionalParam Optional attribute for the string
 */
@UiThread
void alert(@StringRes int messageId, @Nullable Object optionalParam) {
    if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
        throw new RuntimeException("Dialog could be shown only from the main thread");
    }

    AlertDialog.Builder bld = new AlertDialog.Builder(this);
    bld.setNeutralButton("OK", null);

    if (optionalParam == null) {
        bld.setMessage(messageId);
    } else {
        bld.setMessage(getResources().getString(messageId, optionalParam));
    }

    bld.create().show();
}
 
開發者ID:googlecodelabs,項目名稱:play-billing-codelab,代碼行數:23,代碼來源:GamePlayActivity.java

示例2: showLongSafe

import android.support.annotation.StringRes; //導入依賴的package包/類
/**
 * 安全地顯示長時吐司
 *
 * @param resId 資源Id
 */
public static void showLongSafe(@StringRes final int resId) {
    sHandler.post(new Runnable() {
        @Override
        public void run() {
            show(resId, Toast.LENGTH_LONG);
        }
    });
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:14,代碼來源:ToastUtils.java

示例3: newInstance

import android.support.annotation.StringRes; //導入依賴的package包/類
public static TextInputDialogFragment newInstance(@StringRes int summary, TextInputDialogListener listener) {
    TextInputDialogFragment f = new TextInputDialogFragment();

    Bundle args = new Bundle();
    args.putInt(SUMMARY_RES, summary);
    f.setArguments(args);

    f.mListener = listener;
    return f;
}
 
開發者ID:AndProx,項目名稱:AndProx,代碼行數:11,代碼來源:TextInputDialogFragment.java

示例4: setPositiveButton

import android.support.annotation.StringRes; //導入依賴的package包/類
@NonNull @Override
public BuilderJoinerAndroid setPositiveButton(
        @StringRes int textId,
        @Nullable DialogInterface.OnClickListener listener)
{
    return (BuilderJoinerAndroid) super.setPositiveButton(textId, listener);
}
 
開發者ID:datalink747,項目名稱:Rx_java2_soussidev,代碼行數:8,代碼來源:BuilderJoinerAndroid.java

示例5: showShortSafe

import android.support.annotation.StringRes; //導入依賴的package包/類
/**
 * 安全地顯示短時吐司
 *
 * @param resId 資源Id
 * @param args  參數
 */
public static void showShortSafe(final @StringRes int resId, final Object... args) {
    sHandler.post(new Runnable() {
        @Override
        public void run() {
            show(resId, Toast.LENGTH_SHORT, args);
        }
    });
}
 
開發者ID:Lingzh0ng,項目名稱:BrotherWeather,代碼行數:15,代碼來源:ToastUtils.java

示例6: onLoadingEmpty

import android.support.annotation.StringRes; //導入依賴的package包/類
public void onLoadingEmpty(@StringRes int error){
    if (mTvError != null){
        mTvError.setText(error);
        mTvError.setVisibility(View.VISIBLE);
        mProgressLoading.setVisibility(View.GONE);
        mContainSubView.setVisibility(View.GONE);
    }
}
 
開發者ID:NamTranDev,項目名稱:CleanArchitechture,代碼行數:9,代碼來源:BaseFragmentMvp.java

示例7: suggest

import android.support.annotation.StringRes; //導入依賴的package包/類
/**
 * Provide an array of suggestions to be shown while the user is typing
 * This enables the auto-complete behaviour.
 *
 * @param suggestionStringResArray array of string resources to suggest
 */
public Input suggest(@StringRes int... suggestionStringResArray){
    if (suggestionStringResArray != null && suggestionStringResArray.length > 0) {
        this.suggestionStringResArray = suggestionStringResArray;
    }
    return this;
}
 
開發者ID:eltos,項目名稱:SimpleDialogFragments,代碼行數:13,代碼來源:Input.java

示例8: withUsageHintOnLongClick

import android.support.annotation.StringRes; //導入依賴的package包/類
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static Matcher<? super View> withUsageHintOnLongClick(@StringRes final int resourceId) {
    return new TypeSafeMatcher<View>() {

        private String resourceName;
        private String expectedText;

        @Override
        protected boolean matchesSafely(View view) {
            if (!view.isLongClickable()) {
                return false;
            }

            expectedText = view.getResources().getString(resourceId);
            resourceName = view.getResources().getResourceEntryName(resourceId);

            if (expectedText == null) {
                return false;
            }

            AccessibilityNodeInfo.AccessibilityAction clickAction = findAction(view, AccessibilityNodeInfo.ACTION_LONG_CLICK);
            return expectedText.equals(clickAction.getLabel());
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("is long clickable and has custom usage hint for ACTION_LONG_CLICK from resource id: ").appendValue(resourceId);
            appendResourceNameAndExpectedTextToDescription(description, resourceName, expectedText);
        }
    };
}
 
開發者ID:novoda,項目名稱:espresso-support,代碼行數:32,代碼來源:AccessibilityViewMatchers.java

示例9: showLong

import android.support.annotation.StringRes; //導入依賴的package包/類
@UiThread
public static void showLong(Context context, @StringRes int message) {
    Toast toast = getToast(context);
    if (toast != null) {
        toast.setText(message);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.show();
    }
}
 
開發者ID:jiajieshen,項目名稱:AndroidDevSamples,代碼行數:10,代碼來源:ToastUtil.java

示例10: getThemeDialogAdapterItem

import android.support.annotation.StringRes; //導入依賴的package包/類
private static MaterialSimpleListItem getThemeDialogAdapterItem(@StringRes int title, @DrawableRes int icon, String currentTheme, Activity activity) {
	MaterialSimpleListItem.Builder builder = new MaterialSimpleListItem.Builder(activity)
			.content(title)
			.icon(icon);

	return builder.build();
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:8,代碼來源:DialogService.java

示例11: setToolbarSubtitle

import android.support.annotation.StringRes; //導入依賴的package包/類
@Override
public void setToolbarSubtitle(@StringRes int titleRes, Object... params) {
    ActionBar actionBar = ActivityUtils.supportToolbarFor(this);
    if (Objects.nonNull(actionBar)) {
        actionBar.setSubtitle(getString(titleRes, params));
    }
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:8,代碼來源:GifPagerFragment.java

示例12: getDialog

import android.support.annotation.StringRes; //導入依賴的package包/類
/**
 * 單個按鈕,顯示需要調用show()
 *
 * @param context
 * @param messageResId
 * @param postBtResId
 * @param postListener
 */
public static AlertDialog getDialog(final Context context, @StringRes int messageResId, @StringRes int postBtResId
        , DialogInterface.OnClickListener postListener, boolean cancelable) {
    AlertDialog dialog = new AlertDialog.Builder(context)
            .setPositiveButton(postBtResId, postListener)
            .setCancelable(cancelable)
            .setMessage(messageResId)
            .create();
    return dialog;
}
 
開發者ID:Twelvelines,項目名稱:AndroidMuseumBleManager,代碼行數:18,代碼來源:MyAlertDialog.java

示例13: showShort

import android.support.annotation.StringRes; //導入依賴的package包/類
@UiThread
public static void showShort(Context context, @StringRes int message) {
    Toast toast = getToast(context);
    if (toast != null) {
        toast.setText(message);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.show();
    }
}
 
開發者ID:jiajieshen,項目名稱:AndroidDevSamples,代碼行數:10,代碼來源:ToastUtil.java

示例14: newInstance

import android.support.annotation.StringRes; //導入依賴的package包/類
public static AwesomeDialogFragment newInstance(@StringRes int message, @StringRes int positive, @StringRes int negative) {
    AwesomeDialogFragment fragment = new AwesomeDialogFragment();
    Bundle bundle = new Bundle();
    bundle.putInt(KEY_MESSAGE, message);
    bundle.putInt(KEY_POSITIVE, positive);
    bundle.putInt(KEY_NEGATIVE, negative);
    fragment.setArguments(bundle);
    return fragment;
}
 
開發者ID:akexorcist,項目名稱:Android-DialogExperiment,代碼行數:10,代碼來源:AwesomeDialogFragment.java

示例15: showShortSafe

import android.support.annotation.StringRes; //導入依賴的package包/類
/**
 * 安全地顯示短時吐司
 *
 * @param resId 資源Id
 */
public static void showShortSafe(final @StringRes int resId) {
    sHandler.post(new Runnable() {
        @Override
        public void run() {
            show(resId, Toast.LENGTH_SHORT);
        }
    });
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:14,代碼來源:ToastUtils.java


注:本文中的android.support.annotation.StringRes類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。