Resources getStringArray - 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 getStringArray method.

This code example shows how to use the following methods:getIntArray, getResourceTypeName, getStringArray, obtainTypedArray
7
CodeRank
This code example shows how to use the following methods:getIntArray, getResourceTypeName, getStringArray, obtainTypedArray
7
CodeRank
This code example shows how to use the following methods:getStringArray
        resources = new Activity().getResources();
    } 
 
    @Test(expected = Resources.NotFoundException.class) 
    public void getStringArray_shouldThrowExceptionIfNotFound() throws Exception { 
        resources.getStringArray(-1);
    } 
 
    @Test(expected = Resources.NotFoundException.class) 
    public void getIntegerArray_shouldThrowExceptionIfNotFound() throws Exception { 
        resources.getIntArray(-1);
    } 
 
    @Test 
    public void testConfiguration() { 
        Configuration configuration = resources.getConfiguration();
        assertThat(configuration).isNotNull();
        assertThat(configuration.locale).isNotNull();
    } 
 
6
CodeRank
This code example shows how to use the following methods:getIdentifier, getStringArray
    public SearchEngineInfo(Context context, String name) throws IllegalArgumentException {
        mName = name;
        Resources res = context.getResources();
 
        String packageName = R.class.getPackage().getName();
        int id_data = res.getIdentifier(name, "array", packageName);
        if (id_data == 0) {
            throw new IllegalArgumentException("No resources found for " + name);
        } 
        mSearchEngineData = res.getStringArray(id_data);
 
        if (mSearchEngineData == null) {
            throw new IllegalArgumentException("No data found for " + name);
        } 
        if (mSearchEngineData.length != NUM_FIELDS) {
                throw new IllegalArgumentException(
                        name + " has invalid number of fields - " + mSearchEngineData.length);
        } 
        if (TextUtils.isEmpty(mSearchEngineData[FIELD_SEARCH_URI])) {
            throw new IllegalArgumentException(name + " has an empty search URI");
6
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, getStringArray
    public SearchEngineInfo(Context context, String name) throws IllegalArgumentException {
        mName = name;
        Resources res = context.getResources();
 
        String packageName = R.class.getPackage().getName();
        int id_data = res.getIdentifier(name, "array", packageName);
        if (id_data == 0) {
            throw new IllegalArgumentException("No resources found for " + name);
        } 
        mSearchEngineData = res.getStringArray(id_data);
 
        if (mSearchEngineData == null) {
            throw new IllegalArgumentException("No data found for " + name);
        } 
        if (mSearchEngineData.length != NUM_FIELDS) {
                throw new IllegalArgumentException(
                        name + " has invalid number of fields - " + mSearchEngineData.length);
        } 
        if (TextUtils.isEmpty(mSearchEngineData[FIELD_SEARCH_URI])) {
            throw new IllegalArgumentException(name + " has an empty search URI");
6
CodeRank
This code example shows how to use the following methods:getStringArray
		shadowApp = shadowOf( Robolectric.application );		
	} 
	 
    @Test(expected = Resources.NotFoundException.class) 
    public void getStringArray_shouldThrowExceptionIfNotFound() throws Exception { 
        resources.getStringArray(-1);
    } 
 
    @Test 
    public void testConfiguration() { 
        Configuration configuration = resources.getConfiguration();
        assertThat(configuration, notNullValue());
        assertThat(configuration.locale, notNullValue());
    } 
 
    @Test 
    public void testConfigurationReturnsTheSameInstance() { 
        assertThat(resources.getConfiguration(), is(resources.getConfiguration()));
    } 
 
5
CodeRank
This code example shows how to use the following methods:getStringArray
    return base.getString(id);
  } 
 
  @Override 
  public String[] getStringArray(int id) throws NotFoundException {
    return base.getStringArray(id);
  } 
 
  @Override 
  public CharSequence getText(int id, CharSequence def) {
    return base.getText(id, def);
  } 
 
  @Override 
  public CharSequence getText(int id) throws NotFoundException {
    return base.getText(id);
  } 
 
  @Override 
  public CharSequence[] getTextArray(int id) throws NotFoundException {
4
CodeRank
This code example shows how to use the following methods:getStringArray
        @Override 
        public String[] getStringArray(int id) throws NotFoundException {
            if (id == UNRESTRICTED_ID) {
                return UNRESTRICTED_LIST;
            } else { 
                return mRes.getStringArray(id);
            } 
        } 
 
        @Override 
        public void getValue(int id, TypedValue outValue, boolean resolveRefs)
                throws NotFoundException { 
            mRes.getValue(id, outValue, resolveRefs);
        } 
 
        @Override 
        public String getString(int id) throws NotFoundException {
            return mRes.getString(id);
        } 
 
4
CodeRank
This code example shows how to use the following methods:getStringArray
  } 
 
  @SmallTest 
  public void testGetStringArray() { 
    String[] array = new String[0];
    expect(base.getStringArray(10)).andReturn(array);
    replayAll(); 
 
    assertSame(array, resources.getStringArray(10));
 
    verifyAll(); 
  } 
 
  @SmallTest 
  public void testGetText1() { 
    expect(base.getText(10, "abcde")).andReturn("abcdefg");
    replayAll(); 
 
    assertEquals("abcdefg", resources.getText(10, "abcde"));
 
4
CodeRank

Related Resources getStringArray Questions & Answers:

Other Resources getStringArray Examples

46:	
47:			// load slide menu items
48:			navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
49:	
50:			// nav drawer icons from resources

Read More

24:	
25:			// load slide menu items
26:			navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
27:	
28:			// nav drawer icons from resources

Read More

16:	        
17:	        // storing string resources into Array
18:	        String[] adobe_products = getResources().getStringArray(R.array.adobe_products);
19:	        
20:	        // Binding resources Array to ListAdapter

Read More

2:	AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
3:	// Get the string array
4:	String[] countries = getResources().getStringArray(R.array.countries_array);
5:	// Create the adapter and set it to the AutoCompleteTextView 
6:	ArrayAdapter<String> adapter =

Read More

getStringArray Method Overview
Return the string array associated with a particular resource ID.
See Code Examples for other Android Resources Methods: