List of usage examples for android.content.res Resources obtainTypedArray
@NonNull public TypedArray obtainTypedArray(@ArrayRes int id) throws NotFoundException
From source file:Main.java
public static int[] getIntArray(int resId, Resources mResources) { TypedArray array = mResources.obtainTypedArray(resId); int[] rc = new int[array.length()]; TypedValue value = new TypedValue(); for (int i = 0; i < array.length(); i++) { array.getValue(i, value);/* w ww . j a v a2 s.c o m*/ rc[i] = value.resourceId; } return rc; }
From source file:Main.java
public static String[] getItemStrings(Resources res, int iconsRes) { if (iconsRes == 0) return null; TypedArray array = res.obtainTypedArray(iconsRes); int n = array.length(); String ids[] = new String[n]; for (int i = 0; i < n; ++i) { ids[i] = res.getString(array.getResourceId(i, 0)); }/*from ww w. ja v a 2 s. c o m*/ array.recycle(); return ids; }
From source file:org.gearvrf.controls.model.Apple.java
public static float[] getColor(GVRContext gvrContext) { Resources res = gvrContext.getContext().getResources(); TypedArray colorArray = res.obtainTypedArray(R.array.colors); TypedArray colorTypeValues;//from ww w.jav a2 s .c o m float[] appleColor = new float[3]; colorTypeValues = res.obtainTypedArray(colorArray.getResourceId(Apple.currentMotion, 0)); appleColor[0] = colorTypeValues.getFloat(0, 0); appleColor[1] = colorTypeValues.getFloat(1, 0); appleColor[2] = colorTypeValues.getFloat(2, 0); return Util.normalizeColor(appleColor); }
From source file:org.gearvrf.keyboard.model.SphereStaticList.java
private void getSpheres(GVRContext gvrContext, int array) { listFlag = new ArrayList<GVRSceneObject>(); Resources res = gvrContext.getContext().getResources(); TypedArray spheres = res.obtainTypedArray(array); for (int i = 0; i < spheres.length(); i++) { int type = spheres.getResourceId(i, -1); TypedArray sphere = res.obtainTypedArray(type); SphereFlag objectSphere = new SphereFlag(gvrContext, sphere); Vector3D parentPosition = objectSphere.getInitialPositionVector(); GVRSceneObject parent = new GVRSceneObject(gvrContext, new GVRAndroidResource(gvrContext, R.drawable.hit_area_half), new GVRAndroidResource(gvrContext, R.raw.empty)); parent.setName(SceneObjectNames.SPHERE_FLAG_PARENT); parent.getTransform().setPosition((float) parentPosition.getX(), (float) parentPosition.getY(), (float) parentPosition.getZ()); parent.addChildObject(objectSphere); listFlag.add(parent);// w ww .ja va 2 s. c o m } }
From source file:com.android.contacts.util.MaterialColorMapUtils.java
public MaterialColorMapUtils(Resources resources) { sPrimaryColors = resources.obtainTypedArray(com.android.contacts.R.array.letter_tile_colors); sSecondaryColors = resources.obtainTypedArray(com.android.contacts.R.array.letter_tile_colors_dark); }
From source file:com.jimsuplee.femaleastronauts.FemaleAstronautsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { //photoMap.put("ACAZ C.2 2 seat fighter",R.drawable.belgium); //Shannon_Walker //Dorothy_Marie_Dottie_Metcalf_Lindenburger super.onCreate(savedInstanceState); Context ctx = getApplicationContext(); setContentView(R.layout.activity_female_astronauts); Resources res = ctx.getResources(); String[] options = res.getStringArray(R.array.astronauts); TypedArray icons = res.obtainTypedArray(R.array.astronaut_icons); setListAdapter(new ImageAndTextAdapter(ctx, R.layout.main_list_item, options, icons)); ListView listView = getListView(); listView.setTextFilterEnabled(true); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //Intent i = new Intent(""); Intent iAstronaut = new Intent("com.jimsuplee.femaleastronauts.Astronaut"); //NO/*from w ww.j a v a2s .com*/ //Intent iAstronaut = new Intent("Astronaut"); //NO:This item is not a TextView but is a LinearLayout //String astronautChoice = ((TextView) view).getText().toString(); LinearLayout ll = (LinearLayout) view; TextView tv = (TextView) ll.findViewById(R.id.option_text); String astronautChoice = tv.getText().toString(); iAstronaut.putExtra("astronautChoice", astronautChoice); //startActivityForResult(iAstronaut, 0); //Log.w(TAG, "In Astronaut, about to startActivity(iAstronaut)"); startActivity(iAstronaut); //i.setData(Uri.parse(astronautChoice)); //setResult(RESULT_OK, i); //finish(); } }); }
From source file:net.alexjf.tmm.fragments.IconPickerFragment.java
private void updateIcons() { Resources res = getActivity().getResources(); TypedArray iconCats = res.obtainTypedArray(R.array.iconcats); int numCategories = iconCats.length(); iconCategories = new ArrayList<IconCategory>(numCategories); for (int i = 0; i < numCategories; i++) { int resId = iconCats.peekValue(i).resourceId; if (resId > 0) { IconCategory iconCat = new IconCategory(); TypedArray catInfo = res.obtainTypedArray(resId); iconCat.title = catInfo.getString(0); int entriesResId = catInfo.getResourceId(1, 0); if (entriesResId > 0) { TypedArray icons = res.obtainTypedArray(entriesResId); int numIcons = icons.length(); iconCat.drawableIds = new ArrayList<Integer>(numIcons); for (int j = 0; j < numIcons; j++) { int drawableId = icons.getResourceId(j, 0); iconCat.drawableIds.add(drawableId); }//from www .j av a 2 s . c o m icons.recycle(); } else { Log.e("TMM", "Error reading icon entries of cat with index " + i); } iconCategories.add(iconCat); } else { Log.e("TMM", "Error reading icon category with index " + i); } } iconCats.recycle(); Collections.sort(iconCategories, new IconCategory.Comparator()); }
From source file:pt.ubi.di.pdm.swipe.MainActivity.java
private String[][] getExampleTexts() { Resources res = getResources(); TypedArray ta = res.obtainTypedArray(R.array.text_examples); int n = ta.length(); String[][] array = new String[n][]; for (int i = 0; i < n; ++i) { int id = ta.getResourceId(i, 0); if (id > 0) { array[i] = res.getStringArray(id); WriteBtn(this, array[i][0].toString(), array[i][1].toString()); Log.i("ARRAY", String.valueOf(array[i][0].toString() + "---->" + array[i][1].toString())); } else {// w w w . j av a2s .c om Log.e("GET EXAMPLES", "ESTA ALGO DE ERRADO COM O XAML"); } } ta.recycle(); // Important! return array; }
From source file:com.josecalles.tistiq.mvp.view.MainActivity.java
private void getThemeColorPalette() { Resources resources = getResources(); mBackgrounds = resources.obtainTypedArray(R.array.backgrounds); mPrimaryColors = resources.obtainTypedArray(R.array.primary_colors); mPrimaryDarkColors = resources.obtainTypedArray(R.array.primary_dark_colors); mAccents = resources.obtainTypedArray(R.array.accent_colors); }
From source file:io.imoji.sdk.grid.ui.ResultView.java
private int getDimension(int position) { Resources res = getResources(); TypedArray dimensions = res.obtainTypedArray( viewSize == LARGE ? R.array.search_result_large_dimens : R.array.search_result_small_dimens); int dimension = (int) dimensions.getDimension(position, 0f); dimensions.recycle();// w ww. j a v a 2 s .c o m return dimension; }