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


Java Resources.getText方法代碼示例

本文整理匯總了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);
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:23,代碼來源:RMBTLoopService.java

示例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;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:24,代碼來源:ComponentFragment.java

示例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);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:MenuBuilder.java

示例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);
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:19,代碼來源:ChooseAccountTypeActivity.java

示例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);
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-MediaServer,代碼行數:27,代碼來源:SnakeView.java

示例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);
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:31,代碼來源:MenuBuilder.java

示例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);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:14,代碼來源:DataReductionPreferences.java

示例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;
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:43,代碼來源:LatinKeyboard.java

示例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;
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:15,代碼來源:VideoUtils.java

示例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);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:43,代碼來源:SnakeView.java

示例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;
}
 
開發者ID:brevent,項目名稱:prevent,代碼行數:15,代碼來源:UserGuideActivity.java

示例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;
    }
}
 
開發者ID:YehtutHl,項目名稱:myan,代碼行數:32,代碼來源:smKeyboard.java

示例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);
        }
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:59,代碼來源:LatinKeyboard.java

示例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);
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:76,代碼來源:MediaAppWidgetProvider4x1.java

示例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);
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:59,代碼來源:MediaAppWidgetProvider2x1_Light.java


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