本文整理匯總了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);
}
示例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));
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}