TypedArray hasValue - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TypedArray hasValue method.

This code example shows how to use the following methods:getBoolean, getInt, getText, hasValue
            readBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable);
            readBoolean(keyAttr, R.styleable.Keyboard_Key_enabled);
        } 
 
        private void readText(TypedArray a, int index) {
            if (a.hasValue(index))
                mAttributes.put(index, a.getText(index));
        } 
 
        private void readInt(TypedArray a, int index) {
            if (a.hasValue(index))
                mAttributes.put(index, a.getInt(index, 0));
        } 
 
        private void readFlag(TypedArray a, int index) {
            final Integer value = (Integer)mAttributes.get(index);
            if (a.hasValue(index))
                mAttributes.put(index, a.getInt(index, 0) | (value != null ? value : 0));
        } 
 

6
CodeRank
This code example shows how to use the following methods:getString, hasValue
        public abstract String getString(TypedArray a, int index);
        public abstract int getInt(TypedArray a, int index, int defaultValue);
        public abstract int getFlag(TypedArray a, int index);
 
        protected String parseString(TypedArray a, int index) {
            if (a.hasValue(index)) {
                return KeySpecParser.resolveTextReference(a.getString(index), mTextsSet);
            } 
            return null; 
        } 
 
        protected String[] parseStringArray(TypedArray a, int index) {
            if (a.hasValue(index)) {
                return KeySpecParser.parseCsvString(a.getString(index), mTextsSet);
            } 
            return null; 
        } 
    } 
 
    class EmptyKeyStyle extends KeyStyle { 
5
CodeRank
This code example shows how to use the following methods:getLayoutDimension, hasValue
		 * @see android.view.ViewGroup.LayoutParams#setBaseAttributes(android.content.res.TypedArray, int, int) 
		 */ 
		@Override 
		protected void setBaseAttributes( TypedArray a, int widthAttr, int heightAttr ) {
 
			if ( a.hasValue( widthAttr ) ) {
				width = a.getLayoutDimension( widthAttr, "layout_width" );
			} else { 
				width = MATCH_PARENT;
			} 
 
			if ( a.hasValue( heightAttr ) ) {
				height = a.getLayoutDimension( heightAttr, "layout_height" );
			} else { 
				height = MATCH_PARENT;
			} 
		} 
	} 
 
	/** 
5
CodeRank
This code example shows how to use the following methods:getString, hasValue
    protected KeyStyle(final KeyboardTextsSet textsSet) {
        mTextsSet = textsSet;
    } 
 
    protected String parseString(final TypedArray a, final int index) {
        if (a.hasValue(index)) {
            return KeySpecParser.resolveTextReference(a.getString(index), mTextsSet);
        } 
        return null; 
    } 
 
    protected String[] parseStringArray(final TypedArray a, final int index) {
        if (a.hasValue(index)) {
            final String text = KeySpecParser.resolveTextReference(a.getString(index), mTextsSet);
            return StringUtils.parseCsvString(text);
        } 
        return null; 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:hasValue
            mStyles = styles;
        } 
 
        @Override 
        public String[] getStringArray(final TypedArray a, final int index) {
            if (a.hasValue(index)) {
                return parseStringArray(a, index);
            } 
            final Object value = mStyleAttributes.get(index);
            if (value != null) {
                return (String[])value;
            } 
            final KeyStyle parentStyle = mStyles.get(mParentStyleName);
            return parentStyle.getStringArray(a, index);
        } 
 
        @Override 
        public String getString(final TypedArray a, final int index) {
            if (a.hasValue(index)) {
                return parseString(a, index);
4
CodeRank
This code example shows how to use the following methods:hasValue
        throw new NonEmptyTag(tag, parser);
    } 
 
    public static void checkAttributeExists(TypedArray attr, int attrId, String attrName,
            String tag, XmlPullParser parser) throws XmlPullParserException {
        if (attr.hasValue(attrId))
            return; 
        throw new ParseException( 
                "No " + attrName + " attribute found in <" + tag + "/>", parser);
    } 
} 
4
CodeRank

Related TypedArray hasValue Questions & Answers:

hasValue Method Overview
Determines whether there is an attribute at index.
See Code Examples for other Android TypedArray Methods: