Example usage for android.content.res TypedArray getBoolean

List of usage examples for android.content.res TypedArray getBoolean

Introduction

In this page you can find the example usage for android.content.res TypedArray getBoolean.

Prototype

public boolean getBoolean(@StyleableRes int index, boolean defValue) 

Source Link

Document

Retrieve the boolean value for the attribute at index.

Usage

From source file:Main.java

public static boolean getboolean(Context context, int attr, boolean defaultValue) {
    TypedArray ta = context.obtainStyledAttributes(new int[] { attr });
    boolean bool = ta.getBoolean(0, defaultValue);
    ta.recycle();/*from   w ww.j  a  v  a2 s  . c  o m*/

    return bool;
}

From source file:Main.java

public static boolean getBoolean(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex,
        boolean defaultValue) {
    return a.getBoolean(index, a.getBoolean(fallbackIndex, defaultValue));
}

From source file:Main.java

public static boolean resolveBoolean(Context context, @AttrRes int attr, boolean fallback) {
    TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { attr });
    try {/*from  w  ww .ja va  2 s . c  o m*/
        return a.getBoolean(0, fallback);
    } finally {
        a.recycle();
    }
}

From source file:Main.java

public static boolean getWindowTranslucentStatus(Context context) {
    final TypedArray a = context.obtainStyledAttributes(THEME_ATTRS);

    try {/*w ww.  j  a  va  2  s.  c om*/
        return a.getBoolean(1, false);
    } finally {
        a.recycle();
    }
}

From source file:com.android.datetimepicker.Utils.java

/**
 * Gets the required boolean value from the current context, if possible/available
 * @param context The context to use as reference for the boolean
 * @param attr Attribute id to resolve//from   w  w w  . j av  a 2 s . co m
 * @param fallback Default value to return if no value is specified in theme
 * @return the boolean value from current theme
 */
private static boolean resolveBoolean(Context context, @AttrRes int attr, boolean fallback) {
    TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { attr });
    try {
        return a.getBoolean(0, fallback);
    } finally {
        a.recycle();
    }
}

From source file:com.bilibili.magicasakura.utils.ThemeUtils.java

public static boolean getThemeAttrBoolean(Context context, @AttrRes int attr) {
    TEMP_ARRAY[0] = attr;/*from   w  w  w . j av  a  2 s.co  m*/
    TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY);
    try {
        return a.getBoolean(0, false);
    } finally {
        a.recycle();
    }
}

From source file:com.actionbarsherlock.internal.widget.CapitalizingButton.java

public CapitalizingButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_Button);
    mAllCaps = a.getBoolean(R_styleable_Button_textAllCaps, true);
    a.recycle();/*from   w ww  . j  a v  a  2  s . com*/
}

From source file:cn.ieclipse.af.view.ViewPagerV4.java

private void init(Context context, AttributeSet attrs) {
    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerV4);
        disableWipe = a.getBoolean(R.styleable.ViewPagerV4_disableWipe, false);

        a.recycle();/*w  w  w  .ja  v a  2 s .  c  o m*/
    }

}

From source file:com.actionbarsherlock.internal.widget.CapitalizingTextView.java

public CapitalizingTextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_TextView, defStyle, 0);
    mAllCaps = a.getBoolean(R_styleable_TextView_textAllCaps, true);
    a.recycle();/*from w w w.  j  av  a 2 s . co m*/
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static boolean isFloatingWindow(final Context context) {

    final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.windowIsFloating });
    final boolean b = a.getBoolean(0, false);
    a.recycle();//from   ww w  .j av a2s. c  om
    return b;
}