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

This code example shows how to use the following methods:getValue
        int id = field.getInt(null);
        return id;
    } 
 
    private static int getValueType(Context context, int field_id) {
      TypedValue value = new TypedValue();
      context.getResources().getValue(field_id, value, true);
      return value.type;
    } 
 
    private static InputStream openResource(Context context, Uri uri) {
        assert(uri.getScheme().equals(FILE_SCHEME));
        assert(uri.getPath() != null);
        assert(uri.getPath().startsWith(nativeGetAndroidResourcePath()));
        // The path must be of the form "/android_res/asset_type/asset_name.ext". 
        List<String> pathSegments = uri.getPathSegments();
        if (pathSegments.size() != 3) {
            Log.e(TAG, "Incorrect resource path: " + uri);
            return null; 
        } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getValue
        int id = field.getInt(null);
        return id;
    } 
 
    private static int getValueType(Context context, int field_id) {
      TypedValue value = new TypedValue();
      context.getResources().getValue(field_id, value, true);
      return value.type;
    } 
 
    private static InputStream openResource(Context context, Uri uri) {
        assert(uri.getScheme().equals(FILE_SCHEME));
        assert(uri.getPath() != null);
        assert(uri.getPath().startsWith(nativeGetAndroidResourcePath()));
        // The path must be of the form "/android_res/asset_type/asset_name.ext". 
        List<String> pathSegments = uri.getPathSegments();
        if (pathSegments.size() != 3) {
            Log.e(TAG, "Incorrect resource path: " + uri);
            return null; 
        } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getValue
        tryFlag(R.style.TestFlag1And2, 0x3); 
        tryFlag(R.style.TestFlag1And2And31, 0x40000003); 
    } 
 
    private void tryBoolean(int resid, boolean expected) {
        TypedValue v = new TypedValue();
        mContext.getResources().getValue(resid, v, true);
        assertEquals(TypedValue.TYPE_INT_BOOLEAN, v.type);
        assertEquals("Expecting boolean value " + expected + " got " + v
                + " from TypedValue: in resource 0x" + Integer.toHexString(resid),
                expected, v.data != 0);
        assertEquals("Expecting boolean value " + expected + " got " + v
                + " from getBoolean(): in resource 0x" + Integer.toHexString(resid),
                expected, mContext.getResources().getBoolean(resid));
    } 
 
    @SmallTest 
    public void testBoolean() throws Exception { 
        tryBoolean(R.bool.trueRes, true); 
        tryBoolean(R.bool.falseRes, false); 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getValue
 
    public ResourceMapper() { 
    } 
 
    public static int resolveReference(Context context, int i) {
        TypedValue typedvalue = new TypedValue();
        context.getResources().getValue(i, typedvalue, true);
        if(typedvalue.resourceId != 0)
            i = typedvalue.resourceId;
        return i;
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getValue
        int id = field.getInt(null);
        return id;
    } 
 
    private static int getValueType(Context context, int field_id) {
      TypedValue value = new TypedValue();
      context.getResources().getValue(field_id, value, true);
      return value.type;
    } 
 
    private static InputStream openResource(Context context, Uri uri) {
        assert(uri.getScheme().equals(FILE_SCHEME));
        assert(uri.getPath() != null);
        assert(uri.getPath().startsWith(nativeGetAndroidResourcePath()));
        // The path must be of the form "/android_res/asset_type/asset_name.ext". 
        List<String> pathSegments = uri.getPathSegments();
        if (pathSegments.size() != 3) {
            Log.e(TAG, "Incorrect resource path: " + uri);
            return null; 
        } 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getValue
        return null; 
    } 
 
    public static Drawable getDrawable(Resources res, int resid) {
        TypedValue value = new TypedValue();
        res.getValue(resid, value, true);
        return loadDrawable(res, value);
    } 
 
    public static Drawable getDrawable(TypedArray array, int index) {
        TypedValue value = new TypedValue();
        array.getValue(index, value);
        return loadDrawable(array.getResources(), value);
    } 
 
    public static Drawable loadDrawable(Resources res, TypedValue value)
            throws NotFoundException { 
        if (value == null || value.resourceId <= 0) {
            return null; 
        } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getValue
  } 
 
  @Override 
  public void getValue(int id, TypedValue outValue, boolean resolveRefs)
      throws NotFoundException { 
    base.getValue(id, outValue, resolveRefs);
  } 
 
  @Override 
  public void getValue(String name, TypedValue outValue, boolean resolveRefs)
      throws NotFoundException { 
    base.getValue(name, outValue, resolveRefs);
  } 
 
  @TargetApi(15) 
  @Override 
  public void getValueForDensity(int id, int density, TypedValue outValue, boolean resolveRefs)
      throws NotFoundException { 
    base.getValueForDensity(id, density, outValue, resolveRefs);
  } 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getValue
        } 
 
        @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);
        } 
 
        @Override 
        public String getString(int id, Object... formatArgs) throws NotFoundException {
            return mRes.getString(id, formatArgs);
        } 
 
        @Override 
        public CharSequence getText(int id) throws NotFoundException {
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getValue
  } 
 
  @SmallTest 
  public void testGetValue1() { 
    TypedValue outValue = new TypedValue();
    base.getValue(eq(10), same(outValue), eq(true));
    replayAll(); 
 
    resources.getValue(10, outValue, true);
 
    verifyAll(); 
  } 
 
  @SmallTest 
  public void testGetValue2() { 
    TypedValue outValue = new TypedValue();
    base.getValue(eq("abcde"), same(outValue), eq(true));
    replayAll(); 
 
    resources.getValue("abcde", outValue, true);
4
CodeRank
Experience pair programming with AI  Get Codota for Java
getValue Method Overview
Return the raw data associated with a particular resource ID.
See Code Examples for other Android Resources Methods: