Code example for TypedValue

Methods: getValue

0
        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); 
    }