get Attribute Int Value - Android android.util

Android examples for android.util:AttributeSet

Description

get Attribute Int Value

Demo Code


//package com.java2s;
import android.util.AttributeSet;

public class Main {
    public static int getAttributeIntValue(AttributeSet attrs,
            String namespace, String attribute, int defValue) {
        int ret = defValue;

        if (attrs != null) {
            ret = attrs/*from ww  w .j  ava2s. c  o m*/
                    .getAttributeIntValue(namespace, attribute, defValue);
            if (ret == defValue) {
                int count = attrs.getAttributeCount();
                String temp = null;
                for (int i = 0; i < count; i++) {
                    temp = attrs.getAttributeName(i);
                    if (temp.equals(attribute)) {
                        ret = attrs.getAttributeIntValue(i, defValue);
                        break;
                    }
                }
            }
        }
        return ret;
    }
}

Related Tutorials