Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.util.AttributeSet; public class Main { public static Boolean getBooleanAttribute(final Context context, final AttributeSet attrs, final String namespace, final String name, final Boolean defValue) { final int resId = attrs.getAttributeResourceValue(namespace, name, Integer.MIN_VALUE); if (resId != Integer.MIN_VALUE) { return context.getResources().getBoolean(resId); } String str = attrs.getAttributeValue(namespace, name); return str != null ? Boolean.valueOf(str) : defValue; } }