當前位置: 首頁>>代碼示例>>Java>>正文


Java TypedArray.getIndex方法代碼示例

本文整理匯總了Java中android.content.res.TypedArray.getIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java TypedArray.getIndex方法的具體用法?Java TypedArray.getIndex怎麽用?Java TypedArray.getIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.TypedArray的用法示例。


在下文中一共展示了TypedArray.getIndex方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import android.content.res.TypedArray; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final Resources.Theme theme = context.getTheme();
    int[] styles = new int[]{-2000244};
    TypedArray a = theme.obtainStyledAttributes(
            attrs, styles, defStyleAttr, 0);

    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);
        switch (attr) {
            case -2002018:
                mText = a.getText(attr);
                break;
        }
    }
    a.recycle();
    if (!TextUtils.isEmpty(mText)) {
        setColorText((String) mText);
    }
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:21,代碼來源:ColorTextView.java

示例2: init

import android.content.res.TypedArray; //導入方法依賴的package包/類
/**
 * Called from one of constructors of this view to perform its initialization.
 * <p>
 * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
 * this view specific data from it that can be used to configure this new view instance. The
 * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
 * from the current theme provided by the specified <var>context</var>.
 */
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
	/**
	 * Process attributes.
	 */
	boolean createViewHierarchy = true;
	final TypedArray attributes = mContext.obtainStyledAttributes(attrs, R.styleable.Ui_SpinnerLayout, defStyleAttr, defStyleRes);
	for (int i = 0; i < attributes.getIndexCount(); i++) {
		final int index = attributes.getIndex(i);
		if (index == R.styleable.Ui_SpinnerLayout_uiWithEmptyViewHierarchy) {
			createViewHierarchy = !attributes.getBoolean(index, false);
		}
	}
	attributes.recycle();

	if (createViewHierarchy) {
		addLabelView(new TextViewWidget(context, null, R.attr.uiInputLabelStyle));
		addInputView(new SpinnerWidget(context, null, R.attr.uiSpinnerInputStyle));
		addNoteView(new TextViewWidget(context, null, R.attr.uiInputNoteStyle));
		addConstraintView(new TextViewWidget(context, null, R.attr.uiInputConstraintStyle));
	}
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:30,代碼來源:SpinnerLayout.java

示例3: initAttrs

import android.content.res.TypedArray; //導入方法依賴的package包/類
private void initAttrs(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CornerLabelView, 0, 0);
    for (int i = 0; i < ta.getIndexCount(); i++) {
        int attr = ta.getIndex(i);
        if (attr == R.styleable.CornerLabelView_position) {
            position = ta.getInt(attr, 0);
        } else if (attr == R.styleable.CornerLabelView_side_length) {
            sideLength = ta.getDimensionPixelSize(attr, sideLength);
        } else if (attr == R.styleable.CornerLabelView_text_size) {
            textSize = ta.getDimensionPixelSize(attr, textSize);
        } else if (attr == R.styleable.CornerLabelView_text_color) {
            textColor = ta.getColor(attr, textColor);
        } else if (attr == R.styleable.CornerLabelView_text) {
            text = ta.getString(attr);
        } else if (attr == R.styleable.CornerLabelView_bg_color) {
            bgColor = ta.getColor(attr, bgColor);
        } else if (attr == R.styleable.CornerLabelView_margin_lean_side) {
            marginLeanSide = ta.getDimensionPixelSize(attr, marginLeanSide);
        }
    }
    ta.recycle();
}
 
開發者ID:Othershe,項目名稱:CornerLabelView,代碼行數:23,代碼來源:CornerLabelView.java

示例4: init

import android.content.res.TypedArray; //導入方法依賴的package包/類
/**
 * Called from one of constructors of this view to perform its initialization.
 * <p>
 * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
 * this view specific data from it that can be used to configure this new view instance. The
 * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
 * from the current theme provided by the specified <var>context</var>.
 */
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
	this.mAnimations = Animations.get(this);
	this.mResources = context.getResources();

	/**
	 * Process attributes.
	 */
	final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_EmptyView, defStyleAttr, defStyleRes);
	if (typedArray != null) {
		final int n = typedArray.getIndexCount();
		for (int i = 0; i < n; i++) {
			int index = typedArray.getIndex(i);
			if (index == R.styleable.Ui_EmptyView_android_fadeDuration) {
				setFadeDuration(typedArray.getInt(index, (int) mAnimations.fadeDuration));
			} else if (index == R.styleable.Ui_EmptyView_uiTrimTextEnabled) {
				setTrimTextEnabled(typedArray.getBoolean(index, mTrimTextEnabled));
			}
		}
		typedArray.recycle();
	}

	// If no id has been specified, ensure that we have at least the framework's default one.
	if (getId() == NO_ID) setId(android.R.id.empty);
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:33,代碼來源:EmptyView.java

示例5: initXMLAttrs

import android.content.res.TypedArray; //導入方法依賴的package包/類
void initXMLAttrs(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialShadowFrameLayoutWrapper);
    final int N = a.getIndexCount();
    for (int i = 0; i < N; ++i) {
        int attr = a.getIndex(i);
        if (attr == R.styleable.MaterialShadowFrameLayoutWrapper_shadowAlpha) {
            shadowAlpha = a.getFloat(attr, DEFAULT_SHADOW_ALPHA);
        } else if (attr == R.styleable.MaterialShadowFrameLayoutWrapper_shadowOffsetX) {
            offsetX = a.getFloat(attr, DEFAULT_X_OFFSET);
        } else if (attr == R.styleable.MaterialShadowFrameLayoutWrapper_shadowOffsetY) {
            offsetY = a.getFloat(attr, DEFAULT_Y_OFFSET);
        } else if (attr == R.styleable.MaterialShadowFrameLayoutWrapper_calculateAsync) {
            shouldCalculateAsync = a.getBoolean(attr, DEFAULT_CALCULATE_ASYNC);
        } else if (attr == R.styleable.MaterialShadowFrameLayoutWrapper_animateShadow) {
            shouldAnimateShadow = a.getBoolean(attr, DEFAULT_ANIMATE_SHADOW);
        } else if (attr == R.styleable.MaterialShadowFrameLayoutWrapper_showWhenAllReady) {
            shouldShowWhenAllReady = a.getBoolean(attr, DEFAULT_SHOW_WHEN_ALL_READY);
        } else if (attr == R.styleable.MaterialShadowFrameLayoutWrapper_animationDuration) {
            animationDuration = a.getInteger(attr, DEFAULT_ANIMATION_TIME);
        }
    }
    a.recycle();
}
 
開發者ID:harjot-oberai,項目名稱:MaterialShadows,代碼行數:24,代碼來源:MaterialShadowFrameLayoutWrapper.java

示例6: CircleRotateView

import android.content.res.TypedArray; //導入方法依賴的package包/類
public CircleRotateView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray typedArray = context.getTheme()
            .obtainStyledAttributes(attrs, R.styleable.CircleRotateView, defStyleAttr, 0);
    int n = typedArray.getIndexCount();
    for(int i=0;i<n;i++) {
        int attr = typedArray.getIndex(i);
        //在這個中獲取自定義的styleable屬性
        switch (attr) {
            case R.styleable.CircleRotateView_circle_color:
                //如果獲取不到,則為默認值黑色
                circleColor = typedArray.getColor(attr, Color.BLUE);
                break;
            case R.styleable.CircleRotateView_out_color:
                outColor = typedArray.getColor(attr, Color.RED);
                break;
            case R.styleable.CircleRotateView_stroke_width:
                strokeWidth = typedArray.getDimensionPixelSize(attr, 10);
                break;
            case R.styleable.CircleRotateView_out_color2:
                outColor2 = typedArray.getColor(attr, Color.DKGRAY);
                break;
            case R.styleable.CircleRotateView_circle_color2:
                circleColor2 = typedArray.getColor(attr, Color.CYAN);
                break;
            default:
                break;
        }
    }

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    degree = 0;
    typedArray.recycle();
}
 
開發者ID:lazyparser,項目名稱:xbot_head,代碼行數:37,代碼來源:CircleRotateView.java

示例7: BaseNavigationView

import android.content.res.TypedArray; //導入方法依賴的package包/類
public BaseNavigationView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.BaseNavigationView, defStyleAttr, 0);
    int indexCount = a.getIndexCount();
    //讀取自定義控件的屬性信息
    for (int i = 0; i < indexCount; i++) {
        int itemId = a.getIndex(i);
        if (itemId == R.styleable.BaseNavigationView_autoLayoutEnabled) {
            autoLayoutEnabled = a.getBoolean(itemId, false);
        } else if (itemId == R.styleable.BaseNavigationView_selectedColor) {
            tabSelectedColorId = a.getResourceId(itemId, 0);
        } else if (itemId == R.styleable.BaseNavigationView_unselectedColor) {
            tabUnselectedColorId = a.getResourceId(itemId, 0);
        } else if (itemId == R.styleable.BaseNavigationView_tabNames) {
            tabNames = Utils.getStringArray(this.getContext(), a.getResourceId(itemId, 0));
        } else if (itemId == R.styleable.BaseNavigationView_tabTextSize) {
            tabTextSize = a.getDimensionPixelSize(itemId, 0);
        } else if (itemId == R.styleable.BaseNavigationView_tabIcArraysSelected) {
            tabIcsLight = Utils.getResIdsArray(this.getContext(), a.getResourceId(itemId, 0));
        } else if (itemId == R.styleable.BaseNavigationView_tabIcArraysUnselected) {
            tabIcsDark = Utils.getResIdsArray(this.getContext(), a.getResourceId(itemId, 0));
        } else if (itemId == R.styleable.BaseNavigationView_tabIcPadding) {
            tabIcPadding = a.getDimensionPixelSize(itemId, 0);
        } else if (itemId == R.styleable.BaseNavigationView_tabIcPaddingTop) {
            tabIcPaddingTop = a.getDimensionPixelSize(itemId, 0);
        } else if (itemId == R.styleable.BaseNavigationView_tabIcPaddingBottom) {
            tabIcPaddingBottom = a.getDimensionPixelSize(itemId, 0);
        } else if (itemId == R.styleable.BaseNavigationView_tabTextPadding) {
            tabTextPadding = a.getDimensionPixelSize(itemId, 0);
        } else if (itemId == R.styleable.BaseNavigationView_tabTextPaddingTop) {
            tabTextPaddingTop = a.getDimensionPixelSize(itemId, 0);
        } else if (itemId == R.styleable.BaseNavigationView_tabTextPaddingBottom) {
            tabTextPaddingBottom = a.getDimensionPixelSize(itemId, 0);
        }
    }
    a.recycle();
    initView();
}
 
開發者ID:mao720,項目名稱:BaseNavigationView,代碼行數:40,代碼來源:BaseNavigationView.java

示例8: initAttr

import android.content.res.TypedArray; //導入方法依賴的package包/類
private void initAttr(Context context, AttributeSet attrs){
    if (attrs == null) {
        return;
    }
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LoopView);
    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);
        if(attr == R.styleable.LoopView_npv_ShowCount){
            mShowCount = a.getInt(attr, DEFAULT_SHOW_COUNT);
        }else if(attr == R.styleable.LoopView_npv_DividerColor){
            mDividerColor = a.getColor(attr, DEFAULT_DIVIDER_COLOR);
        }else if(attr == R.styleable.LoopView_npv_DividerHeight){
            mDividerHeight = a.getDimensionPixelSize(attr, DEFAULT_DIVIDER_HEIGHT);
        }else if(attr == R.styleable.LoopView_npv_DividerMarginLeft){
            mDividerMarginL = a.getDimensionPixelSize(attr, DEFAULT_DIVIDER_MARGIN_HORIZONTAL);
        }else if(attr == R.styleable.LoopView_npv_DividerMarginRight){
            mDividerMarginR = a.getDimensionPixelSize(attr, DEFAULT_DIVIDER_MARGIN_HORIZONTAL);
        }else if(attr == R.styleable.LoopView_npv_TextArray){
            mDisplayedValues = convertCharSequenceArrayToStringArray(a.getTextArray(attr));
        }else if(attr == R.styleable.LoopView_npv_TextColorNormal){
            mTextColorNormal = a.getColor(attr, DEFAULT_TEXT_COLOR_NORMAL);
        }else if(attr == R.styleable.LoopView_npv_TextColorSelected){
            mTextColorSelected = a.getColor(attr, DEFAULT_TEXT_COLOR_SELECTED);
        }else if(attr == R.styleable.LoopView_npv_TextColorHint){
            mTextColorHint = a.getColor(attr, DEFAULT_TEXT_COLOR_SELECTED);
        }else if(attr == R.styleable.LoopView_npv_TextSizeNormal){
            mTextSizeNormal = a.getDimensionPixelSize(attr, sp2px(context, DEFAULT_TEXT_SIZE_NORMAL_SP));
        }else if(attr == R.styleable.LoopView_npv_TextSizeSelected){
            mTextSizeSelected = a.getDimensionPixelSize(attr, sp2px(context, DEFAULT_TEXT_SIZE_SELECTED_SP));
        }else if(attr == R.styleable.LoopView_npv_TextSizeHint){
            mTextSizeHint = a.getDimensionPixelSize(attr, sp2px(context, DEFAULT_TEXT_SIZE_HINT_SP));
        }else if(attr == R.styleable.LoopView_npv_MinValue){
            mMinShowIndex = a.getInteger(attr, 0);
        }else if(attr == R.styleable.LoopView_npv_MaxValue){
            mMaxShowIndex = a.getInteger(attr, 0);
        }else if(attr == R.styleable.LoopView_npv_WrapSelectorWheel){
            mWrapSelectorWheel = a.getBoolean(attr, DEFAULT_WRAP_SELECTOR_WHEEL);
        }else if(attr == R.styleable.LoopView_npv_ShowDivider){
            mShowDivider = a.getBoolean(attr, DEFAULT_SHOW_DIVIDER);
        }else if(attr == R.styleable.LoopView_npv_HintText){
            mHintText = a.getString(attr);
        }else if(attr == R.styleable.LoopView_npv_AlternativeHint){
            mAlterHint = a.getString(attr);
        }else if(attr == R.styleable.LoopView_npv_EmptyItemHint){
            mEmptyItemHint = a.getString(attr);
        }else if(attr == R.styleable.LoopView_npv_MarginStartOfHint){
            mMarginStartOfHint = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_MARGIN_START_OF_HINT_DP));
        }else if(attr == R.styleable.LoopView_npv_MarginEndOfHint){
            mMarginEndOfHint = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_MARGIN_END_OF_HINT_DP));
        }else if(attr == R.styleable.LoopView_npv_ItemPaddingVertical){
            mItemPaddingVertical = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_ITEM_PADDING_DP_V));
        }else if(attr == R.styleable.LoopView_npv_ItemPaddingHorizontal){
            mItemPaddingHorizontal = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_ITEM_PADDING_DP_H));
        }else if(attr == R.styleable.LoopView_npv_AlternativeTextArrayWithMeasureHint){
            mAlterTextArrayWithMeasureHint = a.getTextArray(attr);
        }else if(attr == R.styleable.LoopView_npv_AlternativeTextArrayWithoutMeasureHint){
            mAlterTextArrayWithoutMeasureHint = a.getTextArray(attr);
        }else if(attr == R.styleable.LoopView_npv_RespondChangeOnDetached){
            mRespondChangeOnDetach = a.getBoolean(attr, DEFAULT_RESPOND_CHANGE_ON_DETACH);
        }else if(attr == R.styleable.LoopView_npv_RespondChangeInMainThread){
            mRespondChangeInMainThread = a.getBoolean(attr, DEFAULT_RESPOND_CHANGE_IN_MAIN_THREAD);
        }else if (attr == R.styleable.LoopView_npv_TextEllipsize) {
            mTextEllipsize = a.getString(attr);
        }
    }
    a.recycle();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:69,代碼來源:PickerView.java

示例9: init

import android.content.res.TypedArray; //導入方法依賴的package包/類
/**
 * 初始化方法
 *
 * @param context
 * @param attrs
 * @param defStyleAttr
 */
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    //創建輔助對象
    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mScaledTouchSlop = viewConfiguration.getScaledTouchSlop();
    mScroller = new Scroller(context);
    //1、獲取配置的屬性值
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.EasySwipeMenuLayout, defStyleAttr, 0);

    try {
        int indexCount = typedArray.getIndexCount();
        for (int i = 0; i < indexCount; i++) {
            int attr = typedArray.getIndex(i);
            if (attr == R.styleable.EasySwipeMenuLayout_leftMenuView) {
                mLeftViewResID = typedArray.getResourceId(R.styleable.EasySwipeMenuLayout_leftMenuView, -1);
            } else if (attr == R.styleable.EasySwipeMenuLayout_rightMenuView) {
                mRightViewResID = typedArray.getResourceId(R.styleable.EasySwipeMenuLayout_rightMenuView, -1);
            } else if (attr == R.styleable.EasySwipeMenuLayout_contentView) {
                mContentViewResID = typedArray.getResourceId(R.styleable.EasySwipeMenuLayout_contentView, -1);
            } else if (attr == R.styleable.EasySwipeMenuLayout_canLeftSwipe) {
                mCanLeftSwipe = typedArray.getBoolean(R.styleable.EasySwipeMenuLayout_canLeftSwipe, true);
            } else if (attr == R.styleable.EasySwipeMenuLayout_canRightSwipe) {
                mCanRightSwipe = typedArray.getBoolean(R.styleable.EasySwipeMenuLayout_canRightSwipe, true);
            } else if (attr == R.styleable.EasySwipeMenuLayout_fraction) {
                mFraction = typedArray.getFloat(R.styleable.EasySwipeMenuLayout_fraction, 0.5f);
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        typedArray.recycle();
    }


}
 
開發者ID:anzaizai,項目名稱:EasySwipeMenuLayout,代碼行數:43,代碼來源:EasySwipeMenuLayout.java

示例10: init

import android.content.res.TypedArray; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FakerGridView, defStyleAttr, 0);
    int count = typedArray.getIndexCount();
    for (int i = 0; i < count; i++) {
        int index = typedArray.getIndex(i);
        if (index == R.styleable.FakerGridView_numColumns) {
            mColumns = typedArray.getInteger(index, COLUMNS_DEFAULT);
        } else if (index == R.styleable.FakerGridView_horizontalSpacing) {
            mHorizontalSpacing = typedArray.getDimensionPixelOffset(index, 0);
        } else if (index == R.styleable.FakerGridView_verticalSpacing) {
            mVerticalSpacing = typedArray.getDimensionPixelOffset(index, 0);
        }
    }
    typedArray.recycle();
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:16,代碼來源:FakerGridView.java

示例11: WaveView

import android.content.res.TypedArray; //導入方法依賴的package包/類
public WaveView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.WaveView, defStyleAttr, 0);
    int n = typedArray.getIndexCount();
    for(int i=0;i<n;i++) {
        int attr = typedArray.getIndex(i);
        switch (attr) {
            case R.styleable.WaveView_inner_color:
                mColor = typedArray.getColor(attr, Color.BLUE);
                mEnableColor = mColor;
                break;
            case R.styleable.WaveView_text:
                textContent = typedArray.getString(attr);
                strStart = strStart + textContent;
                strStop = strStop + textContent;
                break;
            case R.styleable.WaveView_disable_color:
                mDisableColor = typedArray.getColor(attr, Color.GRAY);
                break;
            default:
                break;
        }
    }
    mPaint = new Paint();
    mPaint.setAntiAlias(true);

    //測量文字的高度,以便居中放置
    Rect bound = new Rect();
    mPaint.getTextBounds(strStart, 0, strStart.length(), bound);
    textHeight = bound.height();

    typedArray.recycle();
}
 
開發者ID:lazyparser,項目名稱:xbot_head,代碼行數:34,代碼來源:WaveView.java

示例12: initAttrs

import android.content.res.TypedArray; //導入方法依賴的package包/類
private void initAttrs(@Nullable AttributeSet attrs) {
    if (attrs == null)
        return;

    float density = getResources().getDisplayMetrics().density;
    TypedArray array = getContext().obtainStyledAttributes(attrs,
            R.styleable.ExpandableButtonView);

    for(int index=0;index<array.getIndexCount();index++) {
        int attr=array.getIndex(index);
        if(attr==R.styleable.ExpandableButtonView_button_width) {
            setButtonWidth(array.getDimensionPixelSize(attr, (int) (56 * density)));
        }else if(attr==R.styleable.ExpandableButtonView_button_height) {
            setButtonHeight(array.getDimensionPixelSize(attr, (int) (56 * density)));
        }else if(attr==R.styleable.ExpandableButtonView_button_color) {
            setButtonColor(array.getColor(attr, 0));
        }else if(attr==R.styleable.ExpandableButtonView_button_icon) {
            setButtonIcon(array.getResourceId(attr, -1));
        }else if(attr==R.styleable.ExpandableButtonView_toolbar_color) {
            setToolbarColor(array.getColor(attr, -1));
        }else if(attr==R.styleable.ExpandableButtonView_duration) {
            setDuration(array.getInteger(attr, 150));
        }else if(attr==R.styleable.ExpandableButtonView_reverse_duration){
            setReverseDuration(array.getInteger(attr,150));
        }
    }
    array.recycle();
}
 
開發者ID:vpaliyX,項目名稱:Expandable-Action-Button,代碼行數:29,代碼來源:ExpandableButtonView.java

示例13: onProcessAttributes

import android.content.res.TypedArray; //導入方法依賴的package包/類
@Override
void onProcessAttributes(Context context, TypedArray attributes) {
	super.onProcessAttributes(context, attributes);
	for (int i = 0; i < attributes.getIndexCount(); i++) {
		final int index = attributes.getIndex(i);
		if (index == R.styleable.Ui_HorizontalScrollView_uiHideSoftKeyboardOnTouch) {
			setHideSoftKeyboardOnTouchEnabled(attributes.getBoolean(index, false));
		}
	}
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:11,代碼來源:HorizontalScrollViewWidget.java

示例14: init

import android.content.res.TypedArray; //導入方法依賴的package包/類
/**
 * Called from one of constructors of this view to perform its initialization.
 * <p>
 * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
 * this view specific data from it that can be used to configure this new view instance. The
 * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
 * from the current theme provided by the specified <var>context</var>.
 */
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
	/**
	 * Process attributes.
	 */
	final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_ActionTextButton, defStyleAttr, defStyleRes);
	if (typedArray != null) {
		final int n = typedArray.getIndexCount();
		for (int i = 0; i < n; i++) {
			final int index = typedArray.getIndex(i);
			if (index == R.styleable.Ui_ActionTextButton_android_text) {
				setText(typedArray.getText(index));
			} else if (index == R.styleable.Ui_ActionTextButton_android_paddingLeft) {
				setPadding(
						typedArray.getDimensionPixelSize(index, 0),
						getPaddingTop(),
						getPaddingRight(),
						getPaddingBottom()
				);
			} else if (index == R.styleable.Ui_ActionTextButton_android_paddingRight) {
				setPadding(
						getPaddingLeft(),
						getPaddingTop(),
						typedArray.getDimensionPixelSize(index, 0),
						getPaddingBottom()
				);
			}
		}
		typedArray.recycle();
	}
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:39,代碼來源:ActionTextButton.java

示例15: MomentPicView

import android.content.res.TypedArray; //導入方法依賴的package包/類
public MomentPicView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MomentPicView);
        try {
            for (int i = 0; i < a.getIndexCount(); i++) {
                int attr = a.getIndex(i);
                switch (attr) {
                    case R.styleable.MomentPicView_mpvHorizontalSpace:
                        mHorizontalSpace = a.getDimensionPixelSize(attr, mHorizontalSpace);
                        break;
                    case R.styleable.MomentPicView_mpvVerticalSpace:
                        mVerticalSpace = a.getDimensionPixelSize(attr, mVerticalSpace);
                        break;
                    case R.styleable.MomentPicView_mpvRadius:
                        mRadius = a.getDimensionPixelSize(attr, mRadius);
                        break;
                    case R.styleable.MomentPicView_mpvRatio:
                        mRatio = a.getFloat(attr, mRatio);
                        break;
                }
            }
        } finally {
            a.recycle();
        }
    }

    mPaint.setAntiAlias(true);
    mTextPaint.setAntiAlias(true);
    mPlaceHolder = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_placeholder);

    setImageUrls(null);
}
 
開發者ID:HotBitmapGG,項目名稱:Acg,代碼行數:34,代碼來源:MomentPicView.java


注:本文中的android.content.res.TypedArray.getIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。