get Attribute String Value - Android android.util

Android examples for android.util:AttributeSet

Description

get Attribute String Value

Demo Code


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

public class Main {
    public static String getAttributeStringValue(AttributeSet attrs,
            String namespace, String attribute) {
        String ret = null;// w w w.ja va 2 s  .co m

        if (attrs != null) {
            ret = attrs.getAttributeValue(namespace, attribute);
            if (ret == null) {
                int count = attrs.getAttributeCount();
                String temp = null;
                for (int i = 0; i < count; i++) {
                    temp = attrs.getAttributeName(i);
                    if (temp.equals(attribute)) {
                        ret = attrs.getAttributeValue(i);
                        break;
                    }
                }
            }
        }

        return ret;
    }
}

Related Tutorials