当前位置: 首页>>代码示例>>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;未经允许,请勿转载。