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:com.cytmxk.test.animation.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*  w  w  w  .j a va2 s .co  m*/

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();
}

From source file:com.handmark.pulltorefresh.library.PullToRefreshListView.java

@Override
protected void handleStyledAttributes(TypedArray a) {
    super.handleStyledAttributes(a);

    mListViewExtrasEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrListViewExtrasEnabled, true);

    if (mListViewExtrasEnabled) {
        final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL);

        // Create Loading Views ready for use later
        FrameLayout frame = new FrameLayout(getContext());
        mHeaderLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_START, a);
        mHeaderLoadingView.setVisibility(View.GONE);
        frame.addView(mHeaderLoadingView, lp);
        mRefreshableView.addHeaderView(frame, null, false);

        mLvFooterLoadingFrame = new FrameLayout(getContext());
        mFooterLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_END, a);
        mFooterLoadingView.setVisibility(View.GONE);
        mLvFooterLoadingFrame.addView(mFooterLoadingView, lp);

        /**/*from   w  w w . j  a va 2s  .  c  om*/
         * If the value for Scrolling While Refreshing hasn't been
         * explicitly set via XML, enable Scrolling While Refreshing.
         */
        if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) {
            setScrollingWhileRefreshingEnabled(true);
        }
    }
}

From source file:com.eutectoid.dosomething.picker.FriendPickerFragment.java

@Override
public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.picker_friend_picker_fragment);

    setMultiSelect(a.getBoolean(R.styleable.picker_friend_picker_fragment_multi_select, multiSelect));

    a.recycle();// w  w w .  j av  a 2s.  co  m
}

From source file:com.fenlisproject.elf.core.widget.ExtendedButton.java

@Override
public void setTextAppearance(Context context, int resId) {
    super.setTextAppearance(context, resId);
    TypedArray appearance = context.obtainStyledAttributes(resId, R.styleable.TextAppearance);
    if (appearance.hasValue(R.styleable.TextAppearance_textAllCaps)) {
        setAllCaps(appearance.getBoolean(R.styleable.TextAppearance_textAllCaps, false));
    }//from  w w  w .  j  a v a 2  s.  c  om
    appearance.recycle();
}

From source file:com.android.messaging.ui.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*from w w w .  j av  a 2 s. com*/

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    // enable shadow casting from view bounds
    if (OsUtil.isAtLeastL()) {
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setRect(0, 0, view.getWidth(), view.getHeight());
            }
        });
    }
}

From source file:com.cytmxk.test.picture.blurpicture.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//from   w  w  w  . jav  a 2 s . c  o m

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    // enable shadow casting from view bounds
    setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
}

From source file:am.widget.MaterialProgressImageView.java

private void initView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    final float density = getResources().getDisplayMetrics().density;
    ArrayList<Integer> colors = new ArrayList<>();
    TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.MaterialProgressImageView,
            defStyleAttr, defStyleRes);/*from  www  . ja va  2 s. co  m*/
    boolean autoStart = custom.getBoolean(R.styleable.MaterialProgressImageView_mpiAutoStart, true);
    int color = custom.getColor(R.styleable.MaterialProgressImageView_mpiShadowsCircleColor, DEFAULT_COLOR);
    float elevation = custom.getDimension(R.styleable.MaterialProgressImageView_mpiElevation,
            density * SHADOW_ELEVATION);
    if (custom.hasValue(R.styleable.MaterialProgressImageView_mpiSchemeColor1)) {
        colors.add(custom.getColor(R.styleable.MaterialProgressImageView_mpiSchemeColor1, Color.BLACK));
    }
    if (custom.hasValue(R.styleable.MaterialProgressImageView_mpiSchemeColor2)) {
        colors.add(custom.getColor(R.styleable.MaterialProgressImageView_mpiSchemeColor2, Color.BLACK));
    }
    if (custom.hasValue(R.styleable.MaterialProgressImageView_mpiSchemeColor3)) {
        colors.add(custom.getColor(R.styleable.MaterialProgressImageView_mpiSchemeColor3, Color.BLACK));
    }
    if (custom.hasValue(R.styleable.MaterialProgressImageView_mpiSchemeColor4)) {
        colors.add(custom.getColor(R.styleable.MaterialProgressImageView_mpiSchemeColor4, Color.BLACK));
    }
    if (custom.hasValue(R.styleable.MaterialProgressImageView_mpiSchemeColor5)) {
        colors.add(custom.getColor(R.styleable.MaterialProgressImageView_mpiSchemeColor5, Color.BLACK));
    }
    custom.recycle();
    setElevationCompat(elevation);
    Drawable background = getBackground();
    if (background == null)
        setShadowsCircleBackground(color);
    drawable = new MaterialProgressDrawable(density);
    drawable.setBackgroundColor(0x00000000);
    drawable.setAlpha(255);
    drawable.setCallback(this);
    final int size = colors.size();
    if (size > 0) {
        int[] colorArray = new int[size];
        for (int i = 0; i < size; i++) {
            colorArray[i] = colors.get(i);
        }
        drawable.setColorSchemeColors(colorArray);
    }
    setImageDrawable(drawable);
    if (autoStart)
        start();
}

From source file:am.widget.tabstrip.TabStripView.java

private void initView(Context context, @Nullable AttributeSet attrs) {
    final TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.TabStripView);
    mHelper.set(custom.getResourceId(R.styleable.TabStripView_tsvViewPager, NO_ID),
            custom.getBoolean(R.styleable.TabStripView_tsvAutoFindViewPager, true),
            custom.getBoolean(R.styleable.TabStripView_tsvClickSmoothScroll, false));
    custom.recycle();/*from w  ww.  j a va 2s  .c  om*/
}

From source file:com.example.administrator.iclub21.view.SlideSwitch.java

public SlideSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    listener = null;/*from   w w  w .j av a2s. c o m*/
    paint = new Paint();
    paint.setAntiAlias(true);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.slideswitch);
    color_theme = a.getColor(R.styleable.slideswitch_themeColor, DEFAULT_COLOR_THEME);
    isOpen = a.getBoolean(R.styleable.slideswitch_isOpen, false);
    shape = a.getInt(R.styleable.slideswitch_shape, SHAPE_RECT);
    a.recycle();
}

From source file:am.widget.tabstrip.TabStripViewGroup.java

private void initView(Context context, @Nullable AttributeSet attrs) {
    final TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.TabStripViewGroup);
    mHelper.set(custom.getResourceId(R.styleable.TabStripViewGroup_tsgViewPager, NO_ID),
            custom.getBoolean(R.styleable.TabStripViewGroup_tsgAutoFindViewPager, true),
            custom.getBoolean(R.styleable.TabStripViewGroup_tsgClickSmoothScroll, false));
    custom.recycle();/*from  w  w  w .  j  a v  a 2  s.  c  o  m*/
}