Resources getString - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Resources getString method.

This code example shows how to use the following methods:getIdentifier, getString
        this.attribute = attribute;
    } 
 
    private static String getName(final String attribute, final Resources res, final String packageName) {
        // dynamically search for a translation of the attribute 
        final int id = res.getIdentifier(attribute, "string", packageName);
        if (id > 0) {
            final String translated = res.getString(id);
            if (StringUtils.isNotBlank(translated)) {
                return translated;
            } 
        } 
        return attribute;
    } 
 
    @Override 
    public boolean accepts(final Geocache cache) {
        Geocache fullCache = cgData.loadCache(cache.getGeocode(), EnumSet.of(LoadFlag.LOAD_ATTRIBUTES));
        if (fullCache == null) {
            fullCache = cache;
6
CodeRank
This code example shows how to use the following methods:getDrawable, getString
        public final CharSequence text;
        public final Drawable image;
        public final int actionTag;
         
        public ListItem(Resources res, int textResourceId, int imageResourceId, int actionTag) {
            text = res.getString(textResourceId);
            if (imageResourceId != -1) {
                image = res.getDrawable(imageResourceId);
            } else { 
                image = null;
            } 
            this.actionTag = actionTag;
        } 
    } 
     
    public AddAdapter(Launcher launcher) {
        super(); 
        themeFont=launcher.getThemeFont();
        mInflater = (LayoutInflater) launcher.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         
7
CodeRank
This code example shows how to use the following methods:getString
 
    protected static void setPreference(SharedPreferences prefs, Editor editor, Resources r, int key, int value, boolean ifUnset) {
        if (ifUnset)
            Preferences.setIfUnset(prefs, editor, r, key, value);
        else 
            Preferences.setString(r.getString(key), Integer.toString(value));
    } 
 
    protected static void setPreference(SharedPreferences prefs, Editor editor, Resources r, int key, boolean value, boolean ifUnset) {
        if (ifUnset)
            Preferences.setIfUnset(prefs, editor, r, key, value);
        else 
            Preferences.setBoolean(r.getString(key), value);
    } 
 
    protected static void setPreference(SharedPreferences prefs, Editor editor, Resources r, int key, String value, boolean ifUnset) {
        if (ifUnset)
            Preferences.setIfUnset(prefs, editor, r, key, value);
        else 
            Preferences.setString(r.getString(key), value);
7
CodeRank
This code example shows how to use the following methods:getDrawable, getString
        public final CharSequence text;
        public final Drawable image;
        public final int actionTag;
 
        public ListItem(Resources res, int textResourceId, int imageResourceId, int actionTag) {
            text = res.getString(textResourceId);
            if (imageResourceId != -1) {
                image = res.getDrawable(imageResourceId);
            } else { 
                image = null;
            } 
            this.actionTag = actionTag;
        } 
    } 
     
    public AddAdapter(Launcher launcher) {
        super(); 
 
        mInflater = (LayoutInflater) launcher.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 
7
CodeRank
This code example shows how to use the following methods:getString
        assertEquals(expected, actual);
    } 
 
    private void assertResource(int resId, String ewo, String ew) throws Throwable {
        String expected = mWithOverlay ? ew : ewo;
        String actual = mResources.getString(resId);
        assertEquals(expected, actual);
    } 
 
    private void assertResource(int resId, int[] ewo, int[] ew) throws Throwable {
        int[] expected = mWithOverlay ? ew : ewo;
        int[] actual = mResources.getIntArray(resId);
        assertEquals("length:", expected.length, actual.length);
        for (int i = 0; i < actual.length; ++i) {
            assertEquals("index " + i + ":", actual[i], expected[i]);
        } 
    } 
 
    public void testBooleanOverlay() throws Throwable { 
        // config_automatic_brightness_available has overlay (default config) 
7
CodeRank
This code example shows how to use the following methods:getString, getStringArray
    } 
 
    public static void validateListPreference( Resources res, SharedPreferences prefs, String key, int defaultResId, int arrayResId )
    { 
        String value = prefs.getString( key, null );
        String defValue = res.getString( defaultResId, (String) null );
        String[] validValues = res.getStringArray( arrayResId );
        if( !ArrayUtils.contains( validValues, value ) )
        { 
            prefs.edit().putString( key, defValue ).commit();
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getIdentifier, getString
        this.resources = resources;
    } 
 
    @Nullable 
    public String getText(@NotNull String stringName) {
        final int stringId = this.resources.getIdentifier(stringName, "string", this.packageName);
        try { 
            return resources.getString(stringId);
        } catch (Resources.NotFoundException e) {
            return null; 
        } 
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:getString
    public StringResourceFactory(Resources resources) {
        this.resources = resources;
    } 
 
    public String get(int id) {
        return resources.getString(id);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getIdentifier, getString
 
	@Nullable 
	public String getDescription(@Nonnull String descriptionId) {
		final Resources resources = context.getResources();
 
		final int stringId = resources.getIdentifier(descriptionId, "string", App.getApplication().getClass().getPackage().getName());
		try { 
			return resources.getString(stringId);
		} catch (Resources.NotFoundException e) {
			return null; 
		} 
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getString
        assertEquals(expected, actual);
    } 
 
    private void assertResource(int resId, String ewo, String ew) throws Throwable {
        String expected = mWithOverlay ? ew : ewo;
        String actual = mResources.getString(resId);
        assertEquals(expected, actual);
    } 
 
    private void assertResource(int resId, int[] ewo, int[] ew) throws Throwable {
        int[] expected = mWithOverlay ? ew : ewo;
        int[] actual = mResources.getIntArray(resId);
        assertEquals("length:", expected.length, actual.length);
        for (int i = 0; i < actual.length; ++i) {
            assertEquals("index " + i + ":", actual[i], expected[i]);
        } 
    } 
 
    public void testBooleanOverlay() throws Throwable { 
        // config_automatic_brightness_available has overlay (default config) 
6
CodeRank

Related Resources getString Questions & Answers:

Other Resources getString Examples

14:	    activateDeviceAdminIntent.putExtra(
15:	        DevicePolicyManager.EXTRA_ADD_EXPLANATION,
16:	        getResources().getString(R.string.device_admin_activation_message));
17:	
18:	    startActivityForResult(activateDeviceAdminIntent,

Read More

getString Method Overview
Return the string value associated with a particular resource ID. It will be stripped of any styled text information.
See Code Examples for other Android Resources Methods: