get Attribute Float Value - Android android.util

Android examples for android.util:AttributeSet

Description

get Attribute Float Value

Demo Code


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

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

        if (attrs != null) {
            ret = attrs.getAttributeFloatValue(namespace, attribute,
                    defValue);//from  w ww .  j  a  va  2s.c  o  m
            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.getAttributeFloatValue(i, defValue);
                        break;
                    }
                }
            }
        }
        return ret;
    }
}

Related Tutorials