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


Java Resources.getStringArray方法代碼示例

本文整理匯總了Java中android.content.res.Resources.getStringArray方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getStringArray方法的具體用法?Java Resources.getStringArray怎麽用?Java Resources.getStringArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.getStringArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reinitializeData

import android.content.res.Resources; //導入方法依賴的package包/類
public static void reinitializeData(Context context){

        Resources res = context.getResources();

        if (sharedPref==null) {
            sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
        }

        if (PREF_RECORD_ENTRY==null) {
            PREF_RECORD_LIST_SIZE = "record_list_size";
            PREF_RECORD_ENTRY = "record_entry_";
            PREF_SEARCH_URL = "search_url";
            PREF_ORIENTATION = res.getString(R.string.pref_key_orientation);
            PREF_STATUS_BAR = res.getString(R.string.pref_key_hide_status_bar);
            PREF_LANGUAGE = res.getString(R.string.pref_key_language);

            DEFAULT_SEARCH_URL = res.getStringArray(R.array.search_engine_uris)[5];
            DEFAULT_ORIENTATION = res.getStringArray(R.array.pref_orientation_values)[0];
            DEFAULT_STATUS_BAR = res.getBoolean(R.bool.default_status_bar);
        }
    }
 
開發者ID:TobiasBielefeld,項目名稱:Simple-Search,代碼行數:22,代碼來源:SharedData.java

示例2: getDeviceOverrideValue

import android.content.res.Resources; //導入方法依賴的package包/類
public static String getDeviceOverrideValue(final Resources res, final int overrideResId,
        final String defaultValue) {
    final int orientation = res.getConfiguration().orientation;
    final String key = overrideResId + "-" + orientation;
    if (sDeviceOverrideValueMap.containsKey(key)) {
        return sDeviceOverrideValueMap.get(key);
    }

    final String[] overrideArray = res.getStringArray(overrideResId);
    final String overrideValue = findConstantForKeyValuePairs(sBuildKeyValues, overrideArray);
    // The overrideValue might be an empty string.
    if (overrideValue != null) {
        Log.i(TAG, "Find override value:"
                + " resource="+ res.getResourceEntryName(overrideResId)
                + " build=" + sBuildKeyValuesDebugString
                + " override=" + overrideValue);
        sDeviceOverrideValueMap.put(key, overrideValue);
        return overrideValue;
    }

    sDeviceOverrideValueMap.put(key, defaultValue);
    return defaultValue;
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:24,代碼來源:ResourceUtils.java

示例3: addWallpapers

import android.content.res.Resources; //導入方法依賴的package包/類
private void addWallpapers(ArrayList<WallpaperTileInfo> known, Resources res,
        String packageName, int listResId) {
    final String[] extras = res.getStringArray(listResId);
    for (String extra : extras) {
        int resId = res.getIdentifier(extra, "drawable", packageName);
        if (resId != 0) {
            final int thumbRes = res.getIdentifier(extra + "_small", "drawable", packageName);

            if (thumbRes != 0) {
                ResourceWallpaperInfo wallpaperInfo =
                        new ResourceWallpaperInfo(res, resId, res.getDrawable(thumbRes));
                known.add(wallpaperInfo);
                // Log.d(TAG, "add: [" + packageName + "]: " + extra + " (" + res + ")");
            }
        } else {
            Log.e(TAG, "Couldn't find wallpaper " + extra);
        }
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:20,代碼來源:WallpaperPickerActivity.java

示例4: onCreate

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_guide);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setActionBar(toolbar);

    Resources resources = getResources();
    String[] titles = resources.getStringArray(R.array.fragment_guide);
    String[] messages = resources.getStringArray(R.array.fragment_guide_message);
    String[] messages2 = resources.getStringArray(R.array.fragment_guide_message2);
    String titleShowButton = resources.getString(R.string.fragment_guide_enjoy);

    ViewPager pager = findViewById(R.id.pager);
    pager.setAdapter(new GuidePagerAdapter(getFragmentManager(), titles, titleShowButton,
            messages, messages2));
}
 
開發者ID:brevent,項目名稱:Brevent,代碼行數:19,代碼來源:BreventGuide.java

示例5: genSortTitle

import android.content.res.Resources; //導入方法依賴的package包/類
public String genSortTitle(String a) {
    Resources res = getResources();
    String[] prefixes = res.getStringArray(R.array.ignore_prefixes);
    String a1 = a.trim();

    for (String s : prefixes) {
        String s1 = s + " ";
        if (a1.startsWith(s1))
            return a1.substring(s1.length()).trim();
    }
    return a1;
}
 
開發者ID:n76,項目名稱:Symphony,代碼行數:13,代碼來源:MainActivity.java

示例6: ContentAdapter

import android.content.res.Resources; //導入方法依賴的package包/類
public ContentAdapter(Context context) {
    Resources resources = context.getResources();
    mPlaces = resources.getStringArray(R.array.places);
    mPlaceDesc = resources.getStringArray(R.array.place_desc);
    TypedArray a = resources.obtainTypedArray(R.array.place_avator);
    mPlaceAvators = new Drawable[a.length()];
    for (int i = 0; i < mPlaceAvators.length; i++) {
        mPlaceAvators[i] = a.getDrawable(i);
    }
    a.recycle();
}
 
開發者ID:TORU0239,項目名稱:android-design-library-master,代碼行數:12,代碼來源:ListContentFragment.java

示例7: testInfiniteAdapter

import android.content.res.Resources; //導入方法依賴的package包/類
public void testInfiniteAdapter() {
  final Context context = getContext();
  final Resources res = context.getResources();
  final String[] uris = res.getStringArray(R.array.local_uri_test);
  when(mSimpleAdapter.getSize()).thenReturn(10);
  when(mSimpleAdapter.isLazy()).thenReturn(true);
  when(mSimpleAdapter.get(0)).thenReturn(mUri);
  final SimpleAdapter infinite = SimpleAdapter.Util.makeItInfinite(mSimpleAdapter);
  assertEquals(Integer.MAX_VALUE, infinite.getSize());
  assertTrue(infinite.isLazy());
  assertSame(mUri, infinite.get(0));
  assertSame(mUri, infinite.get(10));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:InfiniteSimpleAdapterTest.java

示例8: ContentAdapter

import android.content.res.Resources; //導入方法依賴的package包/類
public ContentAdapter(Context context) {
    Resources resources = context.getResources();
    mPlaces = resources.getStringArray(R.array.places);
    TypedArray a = resources.obtainTypedArray(R.array.places_picture);
    mPlacePictures = new Drawable[a.length()];
    for (int i = 0; i < mPlacePictures.length; i++) {
        mPlacePictures[i] = a.getDrawable(i);
    }
    a.recycle();
}
 
開發者ID:TORU0239,項目名稱:android-design-library-master,代碼行數:11,代碼來源:TileContentFragment.java

示例9: populateChoiceEntry

import android.content.res.Resources; //導入方法依賴的package包/類
public static void populateChoiceEntry(Resources res, RestrictionEntry reSingleChoice) {
    String[] choiceEntries = res.getStringArray(R.array.choice_entry_entries);
    String[] choiceValues = res.getStringArray(R.array.choice_entry_values);
    if (reSingleChoice.getSelectedString() == null) {
        reSingleChoice.setSelectedString(choiceValues[0]);
    }
    reSingleChoice.setTitle(res.getString(R.string.choice_entry_title));
    reSingleChoice.setChoiceEntries(choiceEntries);
    reSingleChoice.setChoiceValues(choiceValues);
    reSingleChoice.setType(RestrictionEntry.TYPE_CHOICE);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:12,代碼來源:GetRestrictionsReceiver.java

示例10: testLazyAdapter

import android.content.res.Resources; //導入方法依賴的package包/類
public void testLazyAdapter() {
  final Context context = getContext();
  final Resources res = context.getResources();
  final String[] uris = res.getStringArray(R.array.local_uri_test);
  Assert.assertNotNull(uris);
  SimpleAdapter<Uri> simpleAdapter = LocalResourceSimpleAdapter
      .getEagerAdapter(context, R.array.local_uri_test);
  checkSimpleAdapterData(simpleAdapter, uris.length);
  Assert.assertTrue(simpleAdapter.isLazy());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:LocalResourceSimpleAdapterTest.java

示例11: ContentAdapter

import android.content.res.Resources; //導入方法依賴的package包/類
public ContentAdapter(Context context) {
    Resources resources = context.getResources();
    mPlaces = resources.getStringArray(R.array.places);
    mPlaceDesc = resources.getStringArray(R.array.place_desc);
    TypedArray a = resources.obtainTypedArray(R.array.places_picture);
    mPlacePictures = new Drawable[a.length()];
    for (int i = 0; i < mPlacePictures.length; i++) {
        mPlacePictures[i] = a.getDrawable(i);
    }
    a.recycle();
}
 
開發者ID:TORU0239,項目名稱:android-design-library-master,代碼行數:12,代碼來源:CardContentFragment.java

示例12: getQariList

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Get a list of QariItem representing the qaris to show
 *
 * This method takes into account qaris that exist both in gapped and gapless, and, in those
 * cases, hides the gapped version if it contains no files.
 *
 * @param context the current context
 * @return a list of QariItem representing the qaris to show.
 */
public static List<QariItem> getQariList(@NonNull Context context) {
  final Resources resources = context.getResources();
  final String[] shuyookh = resources.getStringArray(R.array.quran_readers_name);
  final String[] paths = resources.getStringArray(R.array.quran_readers_path);
  final String[] urls = resources.getStringArray(R.array.quran_readers_urls);
  final String[] databases = resources.getStringArray(R.array.quran_readers_db_name);
  final int[] hasGaplessEquivalent =
      resources.getIntArray(R.array.quran_readers_have_gapless_equivalents);
  List<QariItem> items = new ArrayList<>(shuyookh.length);
  for (int i=0; i < shuyookh.length; i++) {
    if (hasGaplessEquivalent[i] == 0 || haveAnyFiles(context, paths[i])) {
      items.add(new QariItem(i, shuyookh[i], urls[i], paths[i], databases[i]));
    }
  }
  Collections.sort(items, new Comparator<QariItem>() {
    @Override
    public int compare(QariItem lhs, QariItem rhs) {
      boolean lhsGapless = lhs.isGapless();
      boolean rhsGapless = rhs.isGapless();
      if (lhsGapless != rhsGapless) {
        return lhsGapless ? -1 : 1;
      }
      return lhs.getName().compareTo(rhs.getName());
    }
  });
  return items;
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:37,代碼來源:AudioUtils.java

示例13: updateKeyboardThemeSummary

import android.content.res.Resources; //導入方法依賴的package包/類
static void updateKeyboardThemeSummary(final Preference pref) {
    final Context context = pref.getContext();
    final Resources res = context.getResources();
    final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(context);
    final String[] keyboardThemeNames = res.getStringArray(R.array.keyboard_theme_names);
    final int[] keyboardThemeIds = res.getIntArray(R.array.keyboard_theme_ids);
    for (int index = 0; index < keyboardThemeNames.length; index++) {
        if (keyboardTheme.mThemeId == keyboardThemeIds[index]) {
            pref.setSummary(keyboardThemeNames[index]);
            return;
        }
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:14,代碼來源:ThemeSettingsFragment.java

示例14: populateMultiEntry

import android.content.res.Resources; //導入方法依賴的package包/類
public static void populateMultiEntry(Resources res, RestrictionEntry reMultiSelect) {
    String[] multiEntries = res.getStringArray(R.array.multi_entry_entries);
    String[] multiValues = res.getStringArray(R.array.multi_entry_values);
    if (reMultiSelect.getAllSelectedStrings() == null) {
        reMultiSelect.setAllSelectedStrings(new String[0]);
    }
    reMultiSelect.setTitle(res.getString(R.string.multi_entry_title));
    reMultiSelect.setChoiceEntries(multiEntries);
    reMultiSelect.setChoiceValues(multiValues);
    reMultiSelect.setType(RestrictionEntry.TYPE_MULTI_SELECT);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:12,代碼來源:GetRestrictionsReceiver.java

示例15: getAllIcons

import android.content.res.Resources; //導入方法依賴的package包/類
protected synchronized List<IconBean> getAllIcons(@NonNull Context context) throws Exception {
    if (allIconList != null) {
        List<IconBean> iconList = new ArrayList<>(allIconList.size());
        iconList.addAll(allIconList);
        return iconList;
    }

    Resources resources = context.getResources();
    String[] names = resources.getStringArray(R.array.icons);
    String[] labels = resources.getStringArray(R.array.icon_labels);
    String[] labelPinyins;
    if (labels.length > 0) {
        labelPinyins = ExtraUtil.getPinyinForSorting(labels);
    } else { // No app name list provided, use icon name list instead.
        labels = new String[names.length];
        for (int i = 0, len = names.length; i < len; ++i) {
            labels[i] = names[i].replaceAll("_", " ");
        }
        labelPinyins = Arrays.copyOf(labels, labels.length);
    }
    for (int i = 0, len = labelPinyins.length; i < len; ++i) { // 優化100以內數值邏輯排序
        Matcher matcher = namePattern.matcher(labelPinyins[i]);
        if (matcher.find()) {
            labelPinyins[i] = matcher.replaceAll("0" + matcher.group(0));
        }
    }
    List<IconBean> dataList = new ArrayList<>();
    for (int i = 0, len = names.length; i < len; ++i) {
        int id = resources.getIdentifier(names[i], "drawable",
                context.getPackageName());
        dataList.add(new IconBean(id, names[i], labels[i], labelPinyins[i]));
    }

    // With components
    List<AppfilterReader.Bean> appfilterBeanList = AppfilterReader
            .getInstance(context.getResources()).getDataList();
    for (IconBean iconBean : dataList) {
        for (AppfilterReader.Bean filterBean : appfilterBeanList) {
            if (iconBean.getNameNoSeq().equals(filterBean.getDrawableNoSeq())) {
                iconBean.addComponent(filterBean.getPkg(), filterBean.getLauncher());
                if (iconBean.getName().equals(filterBean.getDrawable())) {
                    iconBean.setDef(true);
                }
            }
        }
    }

    // Check installed
    Map<String, String> installedComponentLabelMap = InstalledAppReader
            .getInstance(context.getPackageManager()).getComponentLabelMap();
    for (IconBean bean : dataList) {
        for (IconBean.Component component : bean.getComponents()) {
            String componentStr = component.getPkg() + "/" + component.getLauncher();
            if (installedComponentLabelMap.containsKey(componentStr)) {
                component.setInstalled(true);
                component.setLabel(installedComponentLabelMap.get(componentStr));
            }
        }
    }

    Collections.sort(dataList);

    allIconList = new ArrayList<>(dataList.size());
    allIconList.addAll(dataList);

    return dataList;
}
 
開發者ID:by-syk,項目名稱:NanoIconPack,代碼行數:68,代碼來源:IconsGetter.java


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