当前位置: 首页>>代码示例>>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;未经允许,请勿转载。