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


Java Resources.getString方法代码示例

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


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

示例1: setIsUsingBigIcon

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Adjusts styling to account for the big icon layout.
 */
public void setIsUsingBigIcon() {
    LayoutParams lp = (LayoutParams) mIconView.getLayoutParams();
    lp.width = mBigIconSize;
    lp.height = mBigIconSize;
    lp.endMargin = mBigIconMargin;

    Resources res = getContext().getResources();
    String typeface = res.getString(R.string.roboto_medium_typeface);
    int textStyle = res.getInteger(R.integer.roboto_medium_textstyle);
    float textSize = res.getDimension(R.dimen.infobar_big_icon_message_size);
    mMessageTextView.setTypeface(Typeface.create(typeface, textStyle));
    mMessageTextView.setMaxLines(1);
    mMessageTextView.setEllipsize(TextUtils.TruncateAt.END);
    mMessageTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:InfoBarLayout.java

示例2: AllAppsGridAdapter

import android.content.res.Resources; //导入方法依赖的package包/类
public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnClickListener
        iconClickListener, View.OnLongClickListener iconLongClickListener) {
    Resources res = launcher.getResources();
    mLauncher = launcher;
    mApps = apps;
    mEmptySearchMessage = res.getString(R.string.all_apps_loading_message);
    mGridSizer = new GridSpanSizer();
    mGridLayoutMgr = new AppsGridLayoutManager(launcher);
    mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
    mItemDecoration = new GridItemDecoration();
    mLayoutInflater = LayoutInflater.from(launcher);
    mIconClickListener = iconClickListener;
    mIconLongClickListener = iconLongClickListener;
    mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin);
    mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset);
    mIsRtl = Utilities.isRtl(res);

    mSectionTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mSectionTextPaint.setTextSize(res.getDimensionPixelSize(
            R.dimen.all_apps_grid_section_text_size));
    mSectionTextPaint.setColor(Utilities.getColorAccent(launcher));
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:23,代码来源:AllAppsGridAdapter.java

示例3: getRequirements

import android.content.res.Resources; //导入方法依赖的package包/类
/**
* Builds a string like that: 300g Rindfleisch (innerhalb der letzten 10 Tage)
   * @return the requirements
   */
  private String getRequirements(Criterion crit) {
      Resources res = crit.getContext().getResources();
      String req = "";
      req += "\u2022 " + crit.getAmountAndCategory() + " ";

      if(crit.getDays() == 1) {
          req += res.getString(R.string.achievement_today_and_yesterday);
      }
      else if(crit.getDays() > 0) {
          req += String.format(res.getString(R.string.achievement_recent_days), crit.getDays());
      }
      else if(crit.getDays() == 0) {
          req += res.getString(R.string.achievement_today);
      }
      
      req += '\n';

      if(crit.getNextCriterion() != null)
          req += getRequirements(crit.getNextCriterion());

      return req;
  }
 
开发者ID:mr-kojo,项目名称:Veggietizer,代码行数:27,代码来源:Achievement.java

示例4: extractADisplayName

import android.content.res.Resources; //导入方法依赖的package包/类
public static String extractADisplayName(Resources r, LinphoneAddress address) {
	if (address == null) return r.getString(R.string.unknown_incoming_call_name);

	final String displayName = address.getDisplayName();
	if (displayName!=null) {
		return displayName;
	} else  if (address.getUserName() != null){
		return address.getUserName();
	} else {
		String rms = address.toString();
		if (rms != null && rms.length() > 1)
			return rms;

		return r.getString(R.string.unknown_incoming_call_name);
	}
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:17,代码来源:LinphoneManager.java

示例5: getSyncErrorHint

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Gets hint message to resolve sync error.
 * @param error The sync error.
 */
private String getSyncErrorHint(@SyncError int error) {
    Resources res = getActivity().getResources();
    switch (error) {
        case SYNC_ANDROID_SYNC_DISABLED:
            return res.getString(R.string.hint_android_sync_disabled);
        case SYNC_AUTH_ERROR:
            return res.getString(R.string.hint_sync_auth_error);
        case SYNC_CLIENT_OUT_OF_DATE:
            return res.getString(
                    R.string.hint_client_out_of_date, BuildInfo.getPackageLabel(getActivity()));
        case SYNC_OTHER_ERRORS:
            return res.getString(R.string.hint_other_sync_errors);
        case SYNC_PASSPHRASE_REQUIRED:
            return res.getString(R.string.hint_passphrase_required);
        case SYNC_NO_ERROR:
        default:
            return null;
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:SyncCustomizationFragment.java

示例6: onBindViewHolder

import android.content.res.Resources; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    ProductFeature feature = mProduct.getFeatures().get(position).first;
    int level = mProduct.getFeatures().get(position).second;
    Resources res = getContext().getResources();
    String stringLevel = res.getString(R.string.product_feature_list_item_level, level);
    holder.textViewName.setText(feature.getName());
    holder.textViewLevel.setText(stringLevel);
    holder.feature = feature;

    // If this is an upgraded feature, also display the level difference.
    if (getItemViewType(position) == UPGRADED) {
        int newLevel = mProduct.getFeatures().get(position).second;
        int oldLevel = mProduct.getReleasedVersion().getFeature(feature.getFeatureId()).second;
        String stringLevelGain = res.getString(R.string.product_feature_list_item_level_gain, newLevel - oldLevel);
        holder.textViewLevelGain.setText(stringLevelGain);
    }
}
 
开发者ID:zak0,项目名称:AppTycoon,代码行数:19,代码来源:NewProductReleaseFragment.java

示例7: getSettingsString

import android.content.res.Resources; //导入方法依赖的package包/类
private String getSettingsString(String stringResName) {
	String stringRes = null;
	try {
		final String settingsPackageName = sSettingsComponentName.getPackageName();
		final Resources resources = mContext.getPackageManager().getResourcesForApplication(settingsPackageName);
		int stringResId = resources.getIdentifier(stringResName, "string", settingsPackageName);
		if (stringResId > 0) {
			String str = resources.getString(stringResId);
			stringRes = str;
		} else {
		}
	} catch (Exception e) {
		CrashReportingManager.logException(e);
	}
	return stringRes;
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:17,代码来源:AppDetailsAutomatorManager.java

示例8: getSubtypeDisplayNameInternal

import android.content.res.Resources; //导入方法依赖的package包/类
@Nonnull
private static String getSubtypeDisplayNameInternal(@Nonnull final InputMethodSubtype subtype,
        @Nonnull final Locale displayLocale) {
    final String replacementString = getReplacementString(subtype, displayLocale);
    // TODO: rework this for multi-lingual subtypes
    final int nameResId = subtype.getNameResId();
    final RunInLocale<String> getSubtypeName = new RunInLocale<String>() {
        @Override
        protected String job(final Resources res) {
            try {
                return res.getString(nameResId, replacementString);
            } catch (Resources.NotFoundException e) {
                // TODO: Remove this catch when InputMethodManager.getCurrentInputMethodSubtype
                // is fixed.
                Log.w(TAG, "Unknown subtype: mode=" + subtype.getMode()
                        + " nameResId=" + subtype.getNameResId()
                        + " locale=" + subtype.getLocale()
                        + " extra=" + subtype.getExtraValue()
                        + "\n" + DebugLogUtils.getStackTrace());
                return "";
            }
        }
    };
    return StringUtils.capitalizeFirstCodePoint(
            getSubtypeName.runInLocale(sResources, displayLocale), displayLocale);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:27,代码来源:SubtypeLocaleUtils.java

示例9: onBindViewHolder

import android.content.res.Resources; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    List<Pair<ProductFeature, Integer>> featureLevels = mProduct.getFeatures();
    final ProductFeature feature = featureLevels.get(position).first;

    holder.textViewFeatureName.setText(feature.getName());

    // Clicking a feature shows a dialog for setting the level of the feature
    // and for removing the feature.
    holder.parent.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showEditFeatureDialog(feature);
        }
    });

    Resources res = AppTycoonApp.getContext().getResources();
    String stringFeatureLevel = res.getString(R.string.product_feature_list_item_level,
            featureLevels.get(position).second);
    holder.textViewFeatureLevel.setText(stringFeatureLevel);
}
 
开发者ID:zak0,项目名称:AppTycoon,代码行数:22,代码来源:NewProductFragment.java

示例10: makeDefaultPlaylists

import android.content.res.Resources; //导入方法依赖的package包/类
private static void makeDefaultPlaylists(Context context) {
    final Resources resources = context.getResources();

    /* Last added list */
    final Playlist lastAdded = new Playlist(TimberUtils.PlaylistType.LastAdded.mId,
            resources.getString(TimberUtils.PlaylistType.LastAdded.mTitleId), -1);
    mPlaylistList.add(lastAdded);

    /* Recently Played */
    final Playlist recentlyPlayed = new Playlist(TimberUtils.PlaylistType.RecentlyPlayed.mId,
            resources.getString(TimberUtils.PlaylistType.RecentlyPlayed.mTitleId), -1);
    mPlaylistList.add(recentlyPlayed);

    /* Top Tracks */
    final Playlist topTracks = new Playlist(TimberUtils.PlaylistType.TopTracks.mId,
            resources.getString(TimberUtils.PlaylistType.TopTracks.mTitleId), -1);
    mPlaylistList.add(topTracks);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:19,代码来源:PlaylistLoader.java

示例11: loadRights

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Load the content for focus:rights
 */
private static void loadRights(@NonNull final AmazonWebView webView) {
    final Context context = webView.getContext();
    final Resources resources = Locales.getLocalizedResources(context);

    final Map<String, String> substitutionMap = new ArrayMap<>();

    final String appName = context.getResources().getString(R.string.app_name);
    final String mplUrl = "https://www.mozilla.org/en-US/MPL/";
    final String trademarkPolicyUrl = "https://www.mozilla.org/foundation/trademarks/policy/";
    final String gplUrl = "gpl.html";
    final String trackingProtectionUrl = "https://wiki.mozilla.org/Security/Tracking_protection#Lists";
    final String licensesUrl = "licenses.html";

    final String content1 = resources.getString(R.string.your_rights_content1, appName);
    substitutionMap.put("%your-rights-content1%", content1);

    final String content2 = resources.getString(R.string.your_rights_content2, appName, mplUrl);
    substitutionMap.put("%your-rights-content2%", content2);

    final String content3 = resources.getString(R.string.your_rights_content3, appName, trademarkPolicyUrl);
    substitutionMap.put("%your-rights-content3%", content3);

    final String content4 = resources.getString(R.string.your_rights_content4, appName, licensesUrl);
    substitutionMap.put("%your-rights-content4%", content4);

    final String content5 = resources.getString(R.string.your_rights_content5, appName, gplUrl, trackingProtectionUrl);
    substitutionMap.put("%your-rights-content5%", content5);

    putLayoutDirectionIntoMap(webView, substitutionMap);

    final String data = HtmlLoader.loadResourceFile(context, R.raw.rights, substitutionMap);
    // We use a file:/// base URL so that we have the right origin to load file:/// css and image resources.
    webView.loadDataWithBaseURL("file:///android_asset/rights.html", data, "text/html", "UTF-8", null);
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:38,代码来源:LocalizedContent.java

示例12: setDetailLineTwo

import android.content.res.Resources; //导入方法依赖的package包/类
public void setDetailLineTwo(TextView view, Resources res) {
    if (mEpisodeTitle == null) {
        view.setText(EMPTY);
    } else {
     // read from R.string.quotation_format, keep a space on
     // the right side of the string
        String quotation = res.getString(R.string.quotation_format);
        view.setText(String.format(quotation, mEpisodeTitle));
    }
    view.setSingleLine(true);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:12,代码来源:EpisodeInfo.java

示例13: getTestStatusString

import android.content.res.Resources; //导入方法依赖的package包/类
public static String getTestStatusString(final Resources res, final TestStatus status)
  {
      switch (status)
      {
      case INIT:
          return res.getString(R.string.test_bottom_test_status_init);
          
      case PING:
          return res.getString(R.string.test_bottom_test_status_ping);
          
      case DOWN:
          return res.getString(R.string.test_bottom_test_status_down);
          
      case INIT_UP:
          return res.getString(R.string.test_bottom_test_status_init_up);
          
      case UP:
          return res.getString(R.string.test_bottom_test_status_up);
          
      case SPEEDTEST_END:
          return res.getString(R.string.test_bottom_test_status_end);
          
      case ERROR:
          return res.getString(R.string.test_bottom_test_status_error);
          
      case ABORTED:
          return res.getString(R.string.test_bottom_test_status_aborted);
          
default:
	break;
          
      }
      return null;
  }
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:35,代码来源:Helperfunctions.java

示例14: getChangeSummary

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Produce a summary of the Zen mode change to be read aloud as TTS.
 */
private CharSequence getChangeSummary(int mode, int minutes) {
    int indefinite = -1;
    int byMinute = -1;
    int byHour = -1;
    int byTime = -1;

    switch (mode) {
        case Global.ZEN_MODE_ALARMS:
            indefinite = R.string.zen_mode_summary_alarms_only_indefinite;
            byMinute = R.plurals.zen_mode_summary_alarms_only_by_minute;
            byHour = R.plurals.zen_mode_summary_alarms_only_by_hour;
            byTime = R.string.zen_mode_summary_alarms_only_by_time;
            break;
        case Global.ZEN_MODE_OFF:
            indefinite = R.string.zen_mode_summary_always;
            break;
    };

    if (minutes < 0 || mode == Global.ZEN_MODE_OFF) {
        return getString(indefinite);
    }

    long time = System.currentTimeMillis() + minutes * MINUTES_MS;
    String skeleton = DateFormat.is24HourFormat(this, UserHandle.myUserId()) ? "Hm" : "hma";
    String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
    CharSequence formattedTime = DateFormat.format(pattern, time);
    Resources res = getResources();

    if (minutes < 60) {
        return res.getQuantityString(byMinute, minutes, minutes, formattedTime);
    } else if (minutes % 60 != 0) {
        return res.getString(byTime, formattedTime);
    } else {
        int hours = minutes / 60;
        return res.getQuantityString(byHour, hours, hours, formattedTime);
    }
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:41,代码来源:ZenModeVoiceActivity.java

示例15: getDurationBreakdown

import android.content.res.Resources; //导入方法依赖的package包/类
public static String getDurationBreakdown(Resources resources, long duration)
{
    duration = max(0, duration);

    long days = TimeUnit.MILLISECONDS.toDays(duration);
    duration -= TimeUnit.DAYS.toMillis(days);
    long hours = TimeUnit.MILLISECONDS.toHours(duration);
    duration -= TimeUnit.HOURS.toMillis(hours);
    long minutes = TimeUnit.MILLISECONDS.toMinutes(duration);

    if (days > 1) {
        return days + " " + resources.getString(R.string.days);
    }
    if (days == 1) {
        return "1 " + resources.getString(R.string.day);
    }
    if (hours > 1) {
        return hours + " " + resources.getString(R.string.hours);
    }
    if (hours == 1) {
        return "1 " + resources.getString(R.string.hour);
    }
    if (minutes > 1) {
        return minutes + " " + resources.getString(R.string.minutes);
    }
    if (minutes == 1) {
        return "1 " + resources.getString(R.string.minute);
    }

    return "0 " + resources.getString(R.string.minutes);
}
 
开发者ID:DorianScholz,项目名称:OpenLibre,代码行数:32,代码来源:AlgorithmUtil.java


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