本文整理匯總了Java中android.content.res.Resources.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getText方法的具體用法?Java Resources.getText怎麽用?Java Resources.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.Resources
的用法示例。
在下文中一共展示了Resources.getText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setNotificationText
import android.content.res.Resources; //導入方法依賴的package包/類
private void setNotificationText(NotificationCompat.Builder builder)
{
final Resources res = getResources();
final long now = SystemClock.elapsedRealtime();
final long lastTestDelta = loopModeResults.getLastTestTime() == 0 ? 0 : now - loopModeResults.getLastTestTime();
final String elapsedTimeString = LoopModeTriggerItem.formatSeconds(Math.round(lastTestDelta / 1000), 1);
final CharSequence textTemplate = res.getText(R.string.loop_notification_text_without_stop);
final CharSequence text = MessageFormat.format(textTemplate.toString(),
loopModeResults.getNumberOfTests(), elapsedTimeString, Math.round(loopModeResults.getLastDistance()));
builder.setContentText(text);
if (bigTextStyle == null)
{
bigTextStyle = (new NotificationCompat.BigTextStyle());
builder.setStyle(bigTextStyle);
}
bigTextStyle.bigText(text);
}
示例2: onCreateView
import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup root,
Bundle savedInstanceState) {
View view;
CharSequence app_name = "NOT FOUND";
try {
// Load resources from UIComponent APK, not from activity APK
Resources res = (Resources) getActivity().getPackageManager()
.getResourcesForApplication(
this.getClass().getPackage().getName());
view = inflater.inflate(res.getXml(R.layout.component), null);
app_name = res.getText(R.string.app_name);
} catch (NameNotFoundException e) {
// Failed to load resources from our own APK
e.printStackTrace();
TextView out = new TextView(getActivity());
out.setText(app_name);
view = out;
}
return view;
}
示例3: setHeaderInternal
import android.content.res.Resources; //導入方法依賴的package包/類
private void setHeaderInternal(int titleRes, CharSequence title, int iconRes, Drawable icon, View view) {
Resources r = getResources();
if (view != null) {
this.mHeaderView = view;
this.mHeaderTitle = null;
this.mHeaderIcon = null;
} else {
if (titleRes > 0) {
this.mHeaderTitle = r.getText(titleRes);
} else if (title != null) {
this.mHeaderTitle = title;
}
if (iconRes > 0) {
this.mHeaderIcon = ContextCompat.getDrawable(getContext(), iconRes);
} else if (icon != null) {
this.mHeaderIcon = icon;
}
this.mHeaderView = null;
}
onItemsChanged(false);
}
示例4: buildTypeToAuthDescriptionMap
import android.content.res.Resources; //導入方法依賴的package包/類
private void buildTypeToAuthDescriptionMap() {
for(AuthenticatorDescription desc : VAccountManager.get().getAuthenticatorTypes()) {
String name = null;
Drawable icon = null;
try {
Resources res = VirtualCore.get().getResources(desc.packageName);
icon = res.getDrawable(desc.iconId);
final CharSequence sequence = res.getText(desc.labelId);
name = sequence.toString();
name = sequence.toString();
} catch (Resources.NotFoundException e) {
// Nothing we can do much here, just log
VLog.w(TAG, "No icon resource for account type " + desc.type);
}
AuthInfo authInfo = new AuthInfo(desc, name, icon);
mTypeToAuthenticatorInfo.put(desc.type, authInfo);
}
}
示例5: SetMode
import android.content.res.Resources; //導入方法依賴的package包/類
public void SetMode(int newMode) {
int prevMode = _mode;
_mode = newMode;
if (newMode == RUNNING & prevMode != RUNNING) {
_statusText.setVisibility(View.INVISIBLE);
Update();
return;
}
Resources resources = getContext().getResources();
CharSequence message = "";
if (newMode == PAUSE) {
message = resources.getText(R.string.mode_pause);
}
if (newMode == READY) {
message = resources.getText(R.string.mode_ready);
}
if (newMode == LOSE) {
message = resources.getString(R.string.mode_lose_prefix) + _score
+ resources.getString(R.string.mode_lose_suffix);
}
_statusText.setText(message);
_statusText.setVisibility(View.VISIBLE);
}
示例6: setHeaderInternal
import android.content.res.Resources; //導入方法依賴的package包/類
private void setHeaderInternal(final int titleRes, final CharSequence title, final int iconRes,
final Drawable icon, final View view) {
final Resources r = getResources();
if (view != null) {
mHeaderView = view;
// If using a custom view, then the title and icon aren't used
mHeaderTitle = null;
mHeaderIcon = null;
} else {
if (titleRes > 0) {
mHeaderTitle = r.getText(titleRes);
} else if (title != null) {
mHeaderTitle = title;
}
if (iconRes > 0) {
mHeaderIcon = r.getDrawable(iconRes);
} else if (icon != null) {
mHeaderIcon = icon;
}
// If using the title or icon, then a custom view isn't used
mHeaderView = null;
}
// Notify of change
onItemsChanged(false);
}
示例7: generateSummary
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Returns summary string.
*/
public static String generateSummary(Resources resources) {
if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) {
String percent = DataReductionProxySettings.getInstance()
.getContentLengthPercentSavings();
return resources.getString(
R.string.data_reduction_menu_item_summary, percent);
} else {
return (String) resources.getText(R.string.text_off);
}
}
示例8: setImeOptions
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* This looks at the ime options given by the current editor, to set the
* appropriate label on the keyboard's enter key (if it has one).
*/
void setImeOptions(Resources res, int options) {
if (mEnterKey == null) {
return;
}
int valnorm = KeyEvent.KEYCODE_ENTER;
switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
case EditorInfo.IME_ACTION_GO:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.codes = NORMAL_ENTER;
mEnterKey.label = res.getText(R.string.label_go_key);
break;
case EditorInfo.IME_ACTION_NEXT:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.codes = NORMAL_ENTER;
mEnterKey.label = res.getText(R.string.label_next_key);
break;
case EditorInfo.IME_ACTION_SEARCH:
mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
mEnterKey.codes = NORMAL_ENTER;
mEnterKey.label = null;
break;
case EditorInfo.IME_ACTION_SEND:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.codes = NORMAL_ENTER;
mEnterKey.label = res.getText(R.string.label_send_key);
break;
default:
mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
mEnterKey.label = null;
mEnterKey.codes = TERMINAL_ENTER;
break;
}
}
示例9: getLanguageString
import android.content.res.Resources; //導入方法依賴的package包/類
static public CharSequence getLanguageString(Context context, CharSequence name) {
final Resources resources = context.getResources();
CharSequence lang;
if(name==null)
return resources.getText(R.string.unknown_track_name);
int resId = resources.getIdentifier((String) name, "string", context.getPackageName());
try {
lang = resources.getText(resId);
} catch (Resources.NotFoundException e) {
lang = name;
}
return lang;
}
示例10: setMode
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Updates the current mode of the application (RUNNING or PAUSED or the like) as well as sets
* the visibility of textview for notification
*
* @param newMode
*/
public void setMode(int newMode) {
int oldMode = mMode;
mMode = newMode;
if (newMode == RUNNING && oldMode != RUNNING) {
// hide the game instructions
mStatusText.setVisibility(View.INVISIBLE);
update();
// make the background and arrows visible as soon the snake starts moving
mArrowsView.setVisibility(View.VISIBLE);
mBackgroundView.setVisibility(View.VISIBLE);
return;
}
Resources res = getContext().getResources();
CharSequence str = "";
if (newMode == PAUSE) {
mArrowsView.setVisibility(View.GONE);
mBackgroundView.setVisibility(View.GONE);
str = res.getText(R.string.mode_pause);
}
if (newMode == READY) {
mArrowsView.setVisibility(View.GONE);
mBackgroundView.setVisibility(View.GONE);
str = res.getText(R.string.mode_ready);
}
if (newMode == LOSE) {
mArrowsView.setVisibility(View.GONE);
mBackgroundView.setVisibility(View.GONE);
str = res.getString(R.string.mode_lose, mScore);
}
mStatusText.setText(str);
mStatusText.setVisibility(View.VISIBLE);
}
示例11: getLabel
import android.content.res.Resources; //導入方法依賴的package包/類
private CharSequence getLabel(PackageManager pm, ApplicationInfo info) throws PackageManager.NameNotFoundException {
CharSequence label = null;
if ("com.android.vending".equals(info.packageName)) {
Resources resources = pm.getResourcesForApplication(info);
int appName = resources.getIdentifier("app_name", "string", info.packageName);
if (appName > 0) {
label = resources.getText(appName);
}
}
if (TextUtils.isEmpty(label)) {
label = pm.getApplicationLabel(info);
}
return label;
}
示例12: setImeOptions
import android.content.res.Resources; //導入方法依賴的package包/類
void setImeOptions(Resources res, int options) {
if (mEnterKey == null) {
return;
}
switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
case EditorInfo.IME_ACTION_GO:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_go_key);
break;
case EditorInfo.IME_ACTION_NEXT:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_next_key);
break;
case EditorInfo.IME_ACTION_SEARCH:
mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
mEnterKey.label = null;
break;
case EditorInfo.IME_ACTION_SEND:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_send_key);
break;
default:
mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
mEnterKey.label = null;
break;
}
}
示例13: setImeOptions
import android.content.res.Resources; //導入方法依賴的package包/類
void setImeOptions(Resources res, int mode, int options) {
mMode = mode;
// TODO should clean up this method
if (mEnterKey != null) {
// Reset some of the rarely used attributes.
mEnterKey.popupCharacters = null;
mEnterKey.popupResId = 0;
mEnterKey.text = null;
switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
case EditorInfo.IME_ACTION_GO:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_go_key);
break;
case EditorInfo.IME_ACTION_NEXT:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_next_key);
break;
case EditorInfo.IME_ACTION_DONE:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_done_key);
break;
case EditorInfo.IME_ACTION_SEARCH:
mEnterKey.iconPreview = res.getDrawable(
R.drawable.sym_keyboard_feedback_search);
mEnterKey.icon = res.getDrawable(mIsBlackSym ?
R.drawable.sym_bkeyboard_search : R.drawable.sym_keyboard_search);
mEnterKey.label = null;
break;
case EditorInfo.IME_ACTION_SEND:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = res.getText(R.string.label_send_key);
break;
default:
if (mode == KeyboardSwitcher.MODE_IM) {
mEnterKey.icon = mHintIcon;
mEnterKey.iconPreview = null;
mEnterKey.label = ":-)";
mEnterKey.text = ":-) ";
mEnterKey.popupResId = R.xml.popup_smileys;
} else {
mEnterKey.iconPreview = res.getDrawable(
R.drawable.sym_keyboard_feedback_return);
mEnterKey.icon = res.getDrawable(mIsBlackSym ?
R.drawable.sym_bkeyboard_return : R.drawable.sym_keyboard_return);
mEnterKey.label = null;
}
break;
}
// Set the initial size of the preview icon
if (mEnterKey.iconPreview != null) {
setDefaultBounds(mEnterKey.iconPreview);
}
}
}
示例14: performUpdate
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Update all active widget instances by pushing changes
*/
public void performUpdate(MediaPlaybackService service, int[] appWidgetIds) {
final Resources res = service.getResources();
final RemoteViews views = new RemoteViews(service.getPackageName(),
R.layout.album_appwidget4x1);
CharSequence titleName = service.getTrackName();
CharSequence artistName = service.getArtistName();
long albumId = service.getAlbumId();
CharSequence errorState = null;
// Format title string with track number, or show SD card message
String status = Environment.getExternalStorageState();
if (status.equals(Environment.MEDIA_SHARED)
|| status.equals(Environment.MEDIA_UNMOUNTED)) {
if (Environment.isExternalStorageRemovable()) {
errorState = res.getText(R.string.sdcard_busy_title);
} else {
errorState = res.getText(R.string.sdcard_busy_title_nosdcard);
}
} else if (status.equals(Environment.MEDIA_REMOVED)) {
if (Environment.isExternalStorageRemovable()) {
errorState = res.getText(R.string.sdcard_missing_title);
} else {
errorState = res
.getText(R.string.sdcard_missing_title_nosdcard);
}
} else if (titleName == null) {
errorState = res.getText(R.string.emptyplaylist);
}
if (errorState != null) {
// Show error state to user
views.setViewVisibility(R.id.title, View.GONE);
views.setTextViewText(R.id.artist, errorState);
views.setImageViewResource(R.id.albumart,
R.drawable.albumart_mp_unknown);
} else {
// No error, so show normal titles and artwork
views.setViewVisibility(R.id.title, View.VISIBLE);
views.setTextViewText(R.id.title, titleName);
views.setTextViewText(R.id.artist, artistName);
views.setViewVisibility(R.id.albumart, View.VISIBLE);
// Set album art
Bitmap art = ((BitmapDrawable) ImageUtils.getArtwork(service, albumId)).getBitmap();
Drawable temp = ImageUtils.getArtworkDownloaded(service, albumId);
if (temp != null) {
art = ((BitmapDrawable) temp).getBitmap();
}
if (art != null) {
views.setImageViewBitmap(R.id.albumart, art);
} else {
views.setImageViewResource(R.id.albumart,
R.drawable.albumart_mp_unknown);
}
}
// Set correct drawable for pause state
final boolean playing = service.isPlaying();
if (playing) {
views.setImageViewResource(R.id.control_play,
android.R.drawable.ic_media_pause);
} else {
views.setImageViewResource(R.id.control_play,
android.R.drawable.ic_media_play);
}
// Link actions buttons to intents
linkButtons(service, views);
pushUpdate(service, appWidgetIds, views);
}
示例15: performUpdate
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Update all active widget instances by pushing changes
*/
public void performUpdate(MediaPlaybackService service, int[] appWidgetIds) {
final Resources res = service.getResources();
final RemoteViews views = new RemoteViews(service.getPackageName(),
R.layout.album_appwidget2x1_light);
CharSequence titleName = service.getTrackName();
CharSequence artistName = service.getArtistName();
CharSequence errorState = null;
// Format title string with track number, or show SD card message
String status = Environment.getExternalStorageState();
if (status.equals(Environment.MEDIA_SHARED)
|| status.equals(Environment.MEDIA_UNMOUNTED)) {
if (Environment.isExternalStorageRemovable()) {
errorState = res.getText(R.string.sdcard_busy_title);
} else {
errorState = res.getText(R.string.sdcard_busy_title_nosdcard);
}
} else if (status.equals(Environment.MEDIA_REMOVED)) {
if (Environment.isExternalStorageRemovable()) {
errorState = res.getText(R.string.sdcard_missing_title);
} else {
errorState = res
.getText(R.string.sdcard_missing_title_nosdcard);
}
} else if (titleName == null) {
errorState = res.getText(R.string.emptyplaylist);
}
if (errorState != null) {
// Show error state to user
views.setViewVisibility(R.id.title, View.GONE);
views.setTextViewText(R.id.artist, errorState);
} else {
// No error, so show normal titles and artwork
views.setViewVisibility(R.id.title, View.VISIBLE);
views.setTextViewText(R.id.title, titleName);
views.setTextViewText(R.id.artist, artistName);
}
// Set correct drawable for pause state
final boolean playing = service.isPlaying();
if (playing) {
views.setImageViewResource(R.id.control_play,
R.drawable.btn_playback_pause_black);
} else {
views.setImageViewResource(R.id.control_play,
R.drawable.btn_playback_play_black);
}
// Link actions buttons to intents
linkButtons(service, views);
pushUpdate(service, appWidgetIds, views);
}