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.android.server.MountService.java

private void readStorageListLocked() {
    mVolumes.clear();//w  w  w .j av  a2  s.  co m
    mVolumeStates.clear();

    Resources resources = mContext.getResources();

    int id = com.android.internal.R.xml.storage_list;
    XmlResourceParser parser = resources.getXml(id);
    AttributeSet attrs = Xml.asAttributeSet(parser);

    try {
        XmlUtils.beginDocument(parser, TAG_STORAGE_LIST);
        while (true) {
            XmlUtils.nextElement(parser);

            String element = parser.getName();
            if (element == null)
                break;

            if (TAG_STORAGE.equals(element)) {
                TypedArray a = resources.obtainAttributes(attrs, com.android.internal.R.styleable.Storage);

                String path = a.getString(com.android.internal.R.styleable.Storage_mountPoint);
                int descriptionId = a.getResourceId(com.android.internal.R.styleable.Storage_storageDescription,
                        -1);
                CharSequence description = a
                        .getText(com.android.internal.R.styleable.Storage_storageDescription);
                boolean primary = a.getBoolean(com.android.internal.R.styleable.Storage_primary, false);
                boolean removable = a.getBoolean(com.android.internal.R.styleable.Storage_removable, false);
                boolean emulated = a.getBoolean(com.android.internal.R.styleable.Storage_emulated, false);
                int mtpReserve = a.getInt(com.android.internal.R.styleable.Storage_mtpReserve, 0);
                boolean allowMassStorage = a
                        .getBoolean(com.android.internal.R.styleable.Storage_allowMassStorage, false);
                boolean allowMtp = a.getBoolean(com.android.internal.R.styleable.Storage_allowMtp, true);
                // resource parser does not support longs, so XML value is in megabytes
                long maxFileSize = a.getInt(com.android.internal.R.styleable.Storage_maxFileSize, 0) * 1024L
                        * 1024L;

                Slog.d(TAG,
                        "got storage path: " + path + " description: " + description + " primary: " + primary
                                + " removable: " + removable + " emulated: " + emulated + " mtpReserve: "
                                + mtpReserve + " allowMassStorage: " + allowMassStorage + " maxFileSize: "
                                + maxFileSize + " allowMtp: " + allowMtp);

                if (emulated) {
                    // For devices with emulated storage, we create separate
                    // volumes for each known user.
                    mEmulatedTemplate = new StorageVolume(null, descriptionId, true, false, true, mtpReserve,
                            false, maxFileSize, null, allowMtp);

                    final UserManagerService userManager = UserManagerService.getInstance();
                    for (UserInfo user : userManager.getUsers(false)) {
                        createEmulatedVolumeForUserLocked(user.getUserHandle());
                    }

                } else {
                    if (path == null || description == null) {
                        Slog.e(TAG, "Missing storage path or description in readStorageList");
                    } else {
                        final StorageVolume volume = new StorageVolume(new File(path), descriptionId, primary,
                                removable, emulated, mtpReserve, allowMassStorage, maxFileSize, null, allowMtp);
                        addVolumeLocked(volume);

                        // Until we hear otherwise, treat as unmounted
                        mVolumeStates.put(volume.getPath(), Environment.MEDIA_UNMOUNTED);
                        volume.setState(Environment.MEDIA_UNMOUNTED);
                    }
                }

                a.recycle();
            }
        }
    } catch (XmlPullParserException e) {
        throw new RuntimeException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        // Compute storage ID for each physical volume; emulated storage is
        // always 0 when defined.
        int index = isExternalStorageEmulated() ? 1 : 0;
        for (StorageVolume volume : mVolumes) {
            if (!volume.isEmulated()) {
                volume.setStorageId(index++);
            }
        }
        parser.close();
    }
}

From source file:com.bulletnoid.android.widget.StaggeredGridView.StaggeredGridView2.java

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

    if (attrs != null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.StgStaggeredGridView);
        mColCount = a.getInteger(R.styleable.StgStaggeredGridView_stgNumColumns, 2);
        mDrawSelectorOnTop = a.getBoolean(R.styleable.StgStaggeredGridView_stgDrawSelectorOnTop, false);
    } else {/*ww  w.  j a  v a 2s.  c o  m*/
        mColCount = 2;
        mDrawSelectorOnTop = false;
    }

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mFlingVelocity = vc.getScaledMinimumFlingVelocity();
    //mScroller=ScrollerCompat.from(context);

    mTopEdge = new EdgeEffectCompat(context);
    mBottomEdge = new EdgeEffectCompat(context);
    setWillNotDraw(false);
    setClipToPadding(false);
    this.setFocusableInTouchMode(false);

    if (mSelector == null) {
        useDefaultSelector();
    }

    mMinimumVelocity = vc.getScaledMinimumFlingVelocity();
    mMaximumVelocity = vc.getScaledMaximumFlingVelocity();
    mOverscrollDistance = vc.getScaledOverscrollDistance(); //TODO
    mOverflingDistance = vc.getScaledOverflingDistance();
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

private void applyXmlAttributes(AttributeSet attrs) {

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingSearchView);

    try {/*w  ww  . java 2 s.c  om*/

        setDismissOnOutsideClick(true);

        int searchBarWidth = a.getDimensionPixelSize(
                R.styleable.FloatingSearchView_floatingSearch_searchBarWidth,
                ViewGroup.LayoutParams.MATCH_PARENT);

        mQuerySection.getLayoutParams().width = searchBarWidth;
        mDivider.getLayoutParams().width = searchBarWidth;
        mSuggestionListContainer.getLayoutParams().width = searchBarWidth;

        int searchBarLeftMargin = a.getDimensionPixelSize(
                R.styleable.FloatingSearchView_floatingSearch_searchBarMarginLeft,
                ATTRS_SEARCH_BAR_MARGIN_DEFAULT);
        int searchBarTopMargin = a.getDimensionPixelSize(
                R.styleable.FloatingSearchView_floatingSearch_searchBarMarginTop,
                ATTRS_SEARCH_BAR_MARGIN_DEFAULT);
        int searchBarRightMargin = a.getDimensionPixelSize(
                R.styleable.FloatingSearchView_floatingSearch_searchBarMarginRight,
                ATTRS_SEARCH_BAR_MARGIN_DEFAULT);

        LayoutParams querySectionLP = (LayoutParams) mQuerySection.getLayoutParams();
        LayoutParams dividerLP = (LayoutParams) mDivider.getLayoutParams();
        LinearLayout.LayoutParams suggestListSectionLP = (LinearLayout.LayoutParams) mSuggestionsSection
                .getLayoutParams();

        querySectionLP.setMargins(searchBarLeftMargin, searchBarTopMargin, searchBarRightMargin, 0);
        dividerLP.setMargins(searchBarLeftMargin, 0, searchBarRightMargin,
                ((MarginLayoutParams) mDivider.getLayoutParams()).bottomMargin);
        suggestListSectionLP.setMargins(searchBarLeftMargin, 0, searchBarRightMargin, 0);

        mQuerySection.setLayoutParams(querySectionLP);
        mDivider.setLayoutParams(dividerLP);
        mSuggestionsSection.setLayoutParams(suggestListSectionLP);

        setSearchHint(a.getString(R.styleable.FloatingSearchView_floatingSearch_searchHint));

        setShowHintWhenNotFocused(
                a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showSearchHintWhenNotFocused,
                        ATTRS_SEARCH_BAR_SHOW_SEARCH_HINT_NOT_FOCUSED_DEFAULT));

        setLeftShowMenu(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showMenuAction,
                ATTRS_SEARCH_BAR_SHOW_MENU_ACTION_DEFAULT));

        setShowVoiceInput(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showVoiceInput,
                ATTRS_SEARCH_BAR_SHOW_VOICE_ACTION_DEFAULT));

        setShowSearchKey(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showSearchKey,
                ATTRS_SEARCH_BAR_SHOW_SEARCH_KEY_DEFAULT));

        setVoiceSearchHint(a.getString(R.styleable.FloatingSearchView_floatingSearch_voiceRecHint));

        setDismissOnOutsideClick(
                a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_dismissOnOutsideTouch,
                        ATTRS_DISMISS_ON_OUTSIDE_TOUCH_DEFAULT));

        setShowOverflowMenu(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showOverFlowMenu,
                ATTRS_SHOW_OVERFLOW_MENU_DEFAULT));

        setSuggestionItemTextSize(
                a.getDimensionPixelSize(R.styleable.FloatingSearchView_floatingSearch_searchSuggestionTextSize,
                        Util.spToPx(ATTRS_SUGGESTION_TEXT_SIZE_SP_DEFAULT)));

        if (a.hasValue(R.styleable.FloatingSearchView_floatingSearch_menu)) {
            inflateOverflowMenu(a.getResourceId(R.styleable.FloatingSearchView_floatingSearch_menu, 0));
        }

        setHideOverflowMenuWhenFocused(
                a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_hideOverflowMenuWhenFocused,
                        ATTRS_HIDE_OVERFLOW_MENU_FOCUSED_DEFAULT));

    } finally {

        a.recycle();
    }
}

From source file:com.dgmltn.ranger.internal.AbsRangeBar.java

public void initialize(TypedArray ta, boolean recycle) {

    Context context = getContext();

    try {/*from ww w  .j  a  v a  2s  .c o m*/
        // Sets the values of the user-defined attributes based on the XML attributes.
        int tickCount = ta.getInt(R.styleable.AbsRangeBar_tickCount, DEFAULT_TICK_COUNT);
        validateTickCount(tickCount);
        mTickCount = tickCount;

        float density = context.getResources().getDisplayMetrics().density;
        mTickSize = ta.getDimension(R.styleable.AbsRangeBar_tickHeight, DEFAULT_TICK_SIZE_DP * density);
        mBarWeight = ta.getDimension(R.styleable.AbsRangeBar_barWeight, DEFAULT_BAR_WEIGHT_DP * density);
        mBarColor = ta.getColor(R.styleable.AbsRangeBar_rangeBarColor, DEFAULT_BAR_COLOR);
        mActiveBarColor = mBarColor;

        int pinTextColor = ta.getColor(R.styleable.AbsRangeBar_textColor, DEFAULT_TEXT_COLOR);
        mFirstPinTextColor = pinTextColor;
        mSecondPinTextColor = pinTextColor;

        int pinColor = ta.getColor(R.styleable.AbsRangeBar_pinColor, DEFAULT_PIN_COLOR);
        mFirstPinColor = pinColor;
        mSecondPinColor = pinColor;

        mSelectorSize = ta.getDimension(R.styleable.AbsRangeBar_selectorSize, DEFAULT_CIRCLE_SIZE_DP * density);
        int selectorColor = ta.getColor(R.styleable.AbsRangeBar_selectorColor, DEFAULT_CONNECTING_LINE_COLOR);
        mFirstSelectorColor = selectorColor;
        mSecondSelectorColor = selectorColor;
        mActiveFirstCircleColor = selectorColor;
        mActiveSecondCircleColor = selectorColor;

        mTickColor = ta.getColor(R.styleable.AbsRangeBar_tickColor, DEFAULT_TICK_COLOR);
        mActiveTickColor = mTickColor;
        mConnectingLineWeight = ta.getDimension(R.styleable.AbsRangeBar_connectingLineWeight,
                DEFAULT_CONNECTING_LINE_WEIGHT_DP * density);

        int connectingLineColor = ta.getColor(R.styleable.AbsRangeBar_connectingLineColor,
                DEFAULT_CONNECTING_LINE_COLOR);
        mFirstConnectingLineColor = connectingLineColor;
        mSecondConnectingLineColor = connectingLineColor;
        mActiveFirstConnectingLineColor = connectingLineColor;
        mActiveSecondConnectingLineColor = connectingLineColor;

        mExpandedPinRadius = ta.getDimension(R.styleable.AbsRangeBar_pinRadius,
                DEFAULT_EXPANDED_PIN_RADIUS_DP * density);
        mPinPadding = ta.getDimension(R.styleable.AbsRangeBar_pinPadding, DEFAULT_PIN_PADDING_DP * density);
        mIsRangeBar = ta.getBoolean(R.styleable.AbsRangeBar_rangeBar, true);
        mArePinsTemporary = ta.getBoolean(R.styleable.AbsRangeBar_temporaryPins, true);

        float scaledDensity = getResources().getDisplayMetrics().scaledDensity;
        mMinPinFont = ta.getDimension(R.styleable.AbsRangeBar_pinMinFont,
                DEFAULT_MIN_PIN_FONT_SP * scaledDensity);
        mMaxPinFont = ta.getDimension(R.styleable.AbsRangeBar_pinMaxFont,
                DEFAULT_MAX_PIN_FONT_SP * scaledDensity);
    } finally {
        if (recycle) {
            ta.recycle();
        }
    }

    initBar();
    initPins(true);
    setTickCount(mTickCount);
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

private void applyXmlAttributes(AttributeSet attrs) {

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingSearchView);

    try {/*from  ww w. ja  va 2s .  co  m*/

        int searchBarWidth = a.getDimensionPixelSize(
                R.styleable.FloatingSearchView_floatingSearch_searchBarWidth,
                ViewGroup.LayoutParams.MATCH_PARENT);
        mQuerySection.getLayoutParams().width = searchBarWidth;
        mDivider.getLayoutParams().width = searchBarWidth;
        mSuggestionListContainer.getLayoutParams().width = searchBarWidth;
        int searchBarLeftMargin = a.getDimensionPixelSize(
                R.styleable.FloatingSearchView_floatingSearch_searchBarMarginLeft,
                ATTRS_SEARCH_BAR_MARGIN_DEFAULT);
        int searchBarTopMargin = a.getDimensionPixelSize(
                R.styleable.FloatingSearchView_floatingSearch_searchBarMarginTop,
                ATTRS_SEARCH_BAR_MARGIN_DEFAULT);
        int searchBarRightMargin = a.getDimensionPixelSize(
                R.styleable.FloatingSearchView_floatingSearch_searchBarMarginRight,
                ATTRS_SEARCH_BAR_MARGIN_DEFAULT);
        LayoutParams querySectionLP = (LayoutParams) mQuerySection.getLayoutParams();
        LayoutParams dividerLP = (LayoutParams) mDivider.getLayoutParams();
        LinearLayout.LayoutParams suggestListSectionLP = (LinearLayout.LayoutParams) mSuggestionsSection
                .getLayoutParams();
        int cardPadding = Util.dpToPx(CARD_VIEW_TOP_BOTTOM_SHADOW_HEIGHT);
        querySectionLP.setMargins(searchBarLeftMargin, searchBarTopMargin, searchBarRightMargin, 0);
        dividerLP.setMargins(searchBarLeftMargin + cardPadding, 0, searchBarRightMargin + cardPadding,
                ((MarginLayoutParams) mDivider.getLayoutParams()).bottomMargin);
        suggestListSectionLP.setMargins(searchBarLeftMargin, 0, searchBarRightMargin, 0);
        mQuerySection.setLayoutParams(querySectionLP);
        mDivider.setLayoutParams(dividerLP);
        mSuggestionsSection.setLayoutParams(suggestListSectionLP);

        setQueryTextSize(
                a.getDimensionPixelSize(R.styleable.FloatingSearchView_floatingSearch_searchInputTextSize,
                        ATTRS_QUERY_TEXT_SIZE_SP_DEFAULT));
        setSearchHint(a.getString(R.styleable.FloatingSearchView_floatingSearch_searchHint));
        setShowSearchKey(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showSearchKey,
                ATTRS_SEARCH_BAR_SHOW_SEARCH_KEY_DEFAULT));
        setCloseSearchOnKeyboardDismiss(
                a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_close_search_on_keyboard_dismiss,
                        ATTRS_DISMISS_ON_KEYBOARD_DISMISS_DEFAULT));
        setDismissOnOutsideClick(
                a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_dismissOnOutsideTouch,
                        ATTRS_DISMISS_ON_OUTSIDE_TOUCH_DEFAULT));
        setSuggestionItemTextSize(
                a.getDimensionPixelSize(R.styleable.FloatingSearchView_floatingSearch_searchSuggestionTextSize,
                        Util.spToPx(ATTRS_SUGGESTION_TEXT_SIZE_SP_DEFAULT)));
        //noinspection ResourceType
        mLeftActionMode = a.getInt(R.styleable.FloatingSearchView_floatingSearch_leftActionMode,
                ATTRS_SEARCH_BAR_LEFT_ACTION_MODE_DEFAULT);
        if (a.hasValue(R.styleable.FloatingSearchView_floatingSearch_menu)) {
            mMenuId = a.getResourceId(R.styleable.FloatingSearchView_floatingSearch_menu, -1);
        }
        setDimBackground(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_dimBackground,
                ATTRS_SHOW_DIM_BACKGROUND_DEFAULT));
        setShowMoveUpSuggestion(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showMoveSuggestionUp,
                ATTRS_SHOW_MOVE_UP_SUGGESTION_DEFAULT));
        this.mSuggestionSectionAnimDuration = a.getInt(
                R.styleable.FloatingSearchView_floatingSearch_suggestionsListAnimDuration,
                ATTRS_SUGGESTION_ANIM_DURATION_DEFAULT);
        setBackgroundColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_backgroundColor,
                Util.getColor(getContext(), R.color.background)));
        setLeftActionIconColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_leftActionColor,
                Util.getColor(getContext(), R.color.left_action_icon)));
        setActionMenuOverflowColor(
                a.getColor(R.styleable.FloatingSearchView_floatingSearch_actionMenuOverflowColor,
                        Util.getColor(getContext(), R.color.overflow_icon_color)));
        setMenuItemIconColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_menuItemIconColor,
                Util.getColor(getContext(), R.color.menu_icon_color)));
        setDividerColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_dividerColor,
                Util.getColor(getContext(), R.color.divider)));
        setClearBtnColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_clearBtnColor,
                Util.getColor(getContext(), R.color.clear_btn_color)));
        int viewTextColor = a.getColor(R.styleable.FloatingSearchView_floatingSearch_viewTextColor,
                Util.getColor(getContext(), R.color.dark_gray));
        setViewTextColor(viewTextColor);
        setQueryTextColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_viewSearchInputTextColor,
                viewTextColor));
        setSuggestionsTextColor(a.getColor(
                R.styleable.FloatingSearchView_floatingSearch_viewSuggestionItemTextColor, viewTextColor));
        setHintTextColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_hintTextColor,
                Util.getColor(getContext(), R.color.hint_color)));
        setSuggestionRightIconColor(
                a.getColor(R.styleable.FloatingSearchView_floatingSearch_suggestionRightIconColor,
                        Util.getColor(getContext(), R.color.gray_active_icon)));
    } finally {
        a.recycle();
    }
}

From source file:com.awrtechnologies.carbudgetsales.hlistview.widget.HListView.java

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

    if (LOG_ENABLED) {
        Log.i(LOG_TAG, "defStyle: " + defStyle);
    }/*from w  w  w.  j a  va  2  s  . c  o m*/

    final Resources.Theme theme = context.getTheme();
    TypedArray array = theme.obtainStyledAttributes(attrs, R.styleable.HListView, defStyle, 0);

    CharSequence[] entries = null;
    Drawable dividerDrawable = null;
    Drawable overscrollHeader = null;
    Drawable overscrollFooter = null;
    int dividerWidth = 0;

    boolean headerDividersEnabled = true;
    boolean footerDividersEnabled = true;
    int measureWithChild = -1;

    if (null != array) {
        entries = array.getTextArray(R.styleable.HListView_android_entries);
        dividerDrawable = array.getDrawable(R.styleable.HListView_android_divider);
        overscrollHeader = array.getDrawable(R.styleable.HListView_hlv_overScrollHeader);
        overscrollFooter = array.getDrawable(R.styleable.HListView_hlv_overScrollFooter);
        dividerWidth = array.getDimensionPixelSize(R.styleable.HListView_hlv_dividerWidth, 0);
        headerDividersEnabled = array.getBoolean(R.styleable.HListView_hlv_headerDividersEnabled, true);
        footerDividersEnabled = array.getBoolean(R.styleable.HListView_hlv_footerDividersEnabled, true);
        measureWithChild = array.getInteger(R.styleable.HListView_hlv_measureWithChild, -1);
        array.recycle();

        if (LOG_ENABLED) {
            Log.d(LOG_TAG, "divider: " + dividerDrawable);
            Log.d(LOG_TAG, "overscrollHeader: " + overscrollHeader);
            Log.d(LOG_TAG, "overscrollFooter: " + overscrollFooter);
            Log.d(LOG_TAG, "dividerWith: " + dividerWidth);
            Log.d(LOG_TAG, "headerDividersEnabled: " + headerDividersEnabled);
            Log.d(LOG_TAG, "footerDividersEnabled: " + footerDividersEnabled);
            Log.d(LOG_TAG, "measureWithChild: " + measureWithChild);
        }
    }

    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }

    if (dividerDrawable != null) {
        // If a divider is specified use its intrinsic height for divider height
        setDivider(dividerDrawable);
    }

    if (overscrollHeader != null) {
        setOverscrollHeader(overscrollHeader);
    }

    if (overscrollFooter != null) {
        setOverscrollFooter(overscrollFooter);
    }

    // Use the height specified, zero being the default
    if (dividerWidth != 0) {
        setDividerWidth(dividerWidth);
    }

    mHeaderDividersEnabled = headerDividersEnabled;
    mFooterDividersEnabled = footerDividersEnabled;
    mMeasureWithChild = measureWithChild;

}

From source file:com.common.widget.hzlib.HorizontalListView.java

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

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListView, defStyle, 0);

    CharSequence[] entries = a.getTextArray(R.styleable.ListView_android_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }// w w  w .j a v  a  2  s  .c  o m

    final Drawable d = a.getDrawable(R.styleable.ListView_android_divider);
    if (d != null) {
        // If a divider is specified use its intrinsic width for divider width
        setDivider(d);
    }

    final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
    if (osHeader != null) {
        setOverscrollHeader(osHeader);
    }

    final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
    if (osFooter != null) {
        setOverscrollFooter(osFooter);
    }

    // Use the width specified, zero being the default
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.ListView_dividerHeight, 0);
    if (dividerHeight != 0) {
        setDividerWidth(dividerHeight);
    }

    mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
    mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

    a.recycle();
}

From source file:com.appunite.list.HorizontalListView.java

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

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListView, defStyle, 0);

    CharSequence[] entries = a.getTextArray(R.styleable.ListView_android_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }/*  w  w  w . ja  v a2  s .  com*/

    final Drawable d = a.getDrawable(R.styleable.ListView_android_divider);
    if (d != null) {
        // If a divider is specified use its intrinsic width for divider width
        setDivider(d);
    }

    final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
    if (osHeader != null) {
        setOverscrollHeader(osHeader);
    }

    final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
    if (osFooter != null) {
        setOverscrollFooter(osFooter);
    }

    // Use the width specified, zero being the default
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.ListView_android_dividerHeight, 0);
    if (dividerHeight != 0) {
        setDividerWidth(dividerHeight);
    }

    mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
    mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

    a.recycle();
}

From source file:com.common.widget.hzlib.ListView.java

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

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListView, defStyle, 0);

    CharSequence[] entries = a.getTextArray(R.styleable.ListView_android_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }/*from w ww .  j a v  a 2  s.  co m*/

    final Drawable d = a.getDrawable(R.styleable.ListView_android_divider);
    if (d != null) {
        // If a divider is specified use its intrinsic width for divider width
        setDivider(d);
    }

    final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
    if (osHeader != null) {
        setOverscrollHeader(osHeader);
    }

    final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
    if (osFooter != null) {
        setOverscrollFooter(osFooter);
    }

    // Use the width specified, zero being the default
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.ListView_dividerHeight, 0);
    if (dividerHeight != 0) {
        setDividerHeight(dividerHeight);
    }

    mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
    mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

    a.recycle();
}

From source file:com.appunite.list.ListView.java

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

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListView, defStyle, 0);

    CharSequence[] entries = a.getTextArray(R.styleable.ListView_android_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<CharSequence>(context, android.R.layout.simple_list_item_1, entries));
    }// w w w. j a va2  s.c  o  m

    final Drawable d = a.getDrawable(R.styleable.ListView_android_divider);
    if (d != null) {
        // If a divider is specified use its intrinsic width for divider width
        setDivider(d);
    }

    final Drawable osHeader = a.getDrawable(R.styleable.ListView_overScrollHeader);
    if (osHeader != null) {
        setOverscrollHeader(osHeader);
    }

    final Drawable osFooter = a.getDrawable(R.styleable.ListView_overScrollFooter);
    if (osFooter != null) {
        setOverscrollFooter(osFooter);
    }

    // Use the width specified, zero being the default
    final int dividerHeight = a.getDimensionPixelSize(R.styleable.ListView_android_dividerHeight, 0);
    if (dividerHeight != 0) {
        setDividerHeight(dividerHeight);
    }

    mHeaderDividersEnabled = a.getBoolean(R.styleable.ListView_headerDividersEnabled, true);
    mFooterDividersEnabled = a.getBoolean(R.styleable.ListView_footerDividersEnabled, true);

    a.recycle();
}