本文整理汇总了Java中android.content.res.TypedArray.getIndexCount方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getIndexCount方法的具体用法?Java TypedArray.getIndexCount怎么用?Java TypedArray.getIndexCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getIndexCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
}
示例2: initCustomAttrs
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initCustomAttrs(Context context, AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.BGABanner);
final int N = typedArray.getIndexCount();
for (int i = 0; i < N; i++) {
initCustomAttr(typedArray.getIndex(i), typedArray);
}
typedArray.recycle();
}
示例3: applyStyle_TextView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static void applyStyle_TextView(TextView v, int styleId) {
TypedArray a = v.getContext().getTheme().obtainStyledAttributes(styleId,
STYLEABLE_ARRAY_TextView);
int N = a.getIndexCount();
for (int i = 0; i < N; i++) {
int attr = a.getIndex(i);
if (attr == STYLEABLE_TextView_textSize) {
int textSize = a.getDimensionPixelSize(attr, 0);
if (textSize != 0) {
v.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
}
} else if (attr == STYLEABLE_TextView_textColor) {
ColorStateList textColor = a.getColorStateList(attr);
v.setTextColor(textColor);
} else if (attr == STYLEABLE_TextView_textColorHint) {
ColorStateList textColorHint = a.getColorStateList(attr);
v.setHintTextColor(textColorHint);
} else if (attr == STYLEABLE_TextView_privateImeOptions) {
String imeOpt = a.getString(attr);
v.setPrivateImeOptions(imeOpt);
} else if(attr == STYLEABLE_TextView_textCursorDrawable){
int mCursorDrawableRes = a.getResourceId(attr, 0);
if(mCursorDrawableRes != 0){
setCursorDrawable(v,mCursorDrawableRes);
}
}
}
a.recycle();
}
示例4: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
public void init(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
final Resources.Theme theme = context.getTheme();
TypedArray a = theme.obtainStyledAttributes(attrs,
com.android.internal.R.styleable.TextView, defStyleAttr, defStyleRes);
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
switch (attr) {
case com.android.internal.R.styleable.TextView_gravity:
mGravity = a.getInt(attr, Gravity.TOP | Gravity.LEFT);
break;
case com.android.internal.R.styleable.TextView_text:
mText = a.getText(attr);
break;
case com.android.internal.R.styleable.TextView_ellipsize:
mEllipsize = a.getInt(attr, mEllipsize);
break;
case com.android.internal.R.styleable.TextView_maxLines:
mMaxLines = a.getInt(attr, Integer.MAX_VALUE);
break;
case com.android.internal.R.styleable.TextView_textColor:
// Do not support ColorState
mTextColor = a.getColor(attr, Color.BLACK);
break;
case com.android.internal.R.styleable.TextView_textSize:
mTextSize = a.getDimensionPixelSize(attr, 15);
break;
case com.android.internal.R.styleable.TextView_lineSpacingExtra:
mSpacingAdd = a.getDimensionPixelSize(attr, mSpacingAdd);
break;
case com.android.internal.R.styleable.TextView_lineSpacingMultiplier:
mSpacingMultiplier = a.getFloat(attr, mSpacingMultiplier);
break;
}
}
}
示例5: 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>.
*/
@SuppressWarnings("ConstantConditions")
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
if (!isInEditMode()) {
final Resources.Theme theme = context.getTheme();
// Try to apply font presented within text appearance style.
final TypedArray appearanceAttributes = theme.obtainStyledAttributes(attrs, new int[]{android.R.attr.textAppearance}, defStyleAttr, defStyleRes);
final int appearance = appearanceAttributes.getResourceId(0, -1);
if (appearance != -1) {
FontApplier.DEFAULT.applyFont(this, appearance);
}
appearanceAttributes.recycle();
// Try to apply font presented within xml attributes.
FontApplier.DEFAULT.applyFont(this, attrs, defStyleAttr, defStyleRes);
}
// Default set up.
this.mLocale = Locale.getDefault();
this.handleLocaleChange();
final TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.Ui_MonthView, defStyleAttr, defStyleRes);
this.processTintValues(context, attributes);
for (int i = 0; i < attributes.getIndexCount(); i++) {
final int index = attributes.getIndex(i);
if (index == R.styleable.Ui_MonthView_android_horizontalSpacing) {
this.mSpacingHorizontal = attributes.getDimensionPixelSize(index, mSpacingHorizontal);
} else if (index == R.styleable.Ui_MonthView_android_verticalSpacing) {
this.mSpacingVertical = attributes.getDimensionPixelSize(index, mSpacingVertical);
} else if (index == R.styleable.Ui_MonthView_uiMonthDayLettersOffsetVertical) {
this.mDayLettersOffsetVertical = attributes.getDimensionPixelSize(index, mDayLettersOffsetVertical);
} else if (index == R.styleable.Ui_MonthView_uiMonthDayNumbersOffsetVertical) {
this.mDayNumbersOffsetVertical = attributes.getDimensionPixelOffset(index, mDayNumbersOffsetVertical);
} else if (index == R.styleable.Ui_MonthView_uiMonthTitleTextAppearance) {
setTitleTextAppearance(attributes.getResourceId(index, 0));
} else if (index == R.styleable.Ui_MonthView_uiMonthDayLetterTextAppearance) {
setDayLetterTextAppearance(attributes.getResourceId(index, 0));
} else if (index == R.styleable.Ui_MonthView_uiMonthDayNumberTextAppearance) {
setDayNumberTextAppearance(attributes.getResourceId(index, 0));
} else if (index == R.styleable.Ui_MonthView_uiMonthDaySelector) {
setDaySelector(attributes.getResourceId(index, 0));
} else if (index == R.styleable.Ui_MonthView_uiMonthDaySelectorRadius) {
setDaySelectorRadius(attributes.getDimensionPixelSize(index, mDaySelectorRadius));
} else if (index == R.styleable.Ui_MonthView_uiMonthCurrentDayTextColor) {
setCurrentDayTextColor(attributes.getColorStateList(index));
}
}
attributes.recycle();
this.applyDaySelectorTint();
}
示例6: CalendarView
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Creates a new instance of CalendarView for the given <var>context</var>.
*
* @param context Context in which will be the new view presented.
* @param attrs Set of Xml attributes used to configure the new instance of this view.
* @param defStyleAttr An attribute which contains a reference to a default style resource for
* this view within a theme of the given context.
*/
public CalendarView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.ensureDecorator();
this.mDecorator.processAttributes(context, attrs, defStyleAttr, 0);
this.mCalendar = Calendar.getInstance();
super.addOnScrollListener(CALLBACKS_HANDLER);
final Resources resources = context.getResources();
final float density = resources.getDisplayMetrics().density;
final TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.Ui_CalendarView, defStyleAttr, 0);
for (int i = 0; i < attributes.getIndexCount(); i++) {
final int index = attributes.getIndex(i);
if (index == R.styleable.Ui_CalendarView_android_orientation) {
this.mOrientation = attributes.getInt(index, mOrientation);
} else if (index == R.styleable.Ui_CalendarView_uiScrollSpeedPerInch) {
this.mScrollSpeedPerInch = attributes.getFloat(index, mScrollSpeedPerInch);
} else if (index == R.styleable.Ui_CalendarView_uiFlingMinVelocity) {
this.mFlingMinVelocity = attributes.getFloat(index, mFlingMinVelocity) * density;
} else if (index == R.styleable.Ui_CalendarView_uiFlingMaxVelocity) {
this.mFlingMaxVelocity = attributes.getFloat(index, mFlingMaxVelocity) * density;
}
}
attributes.recycle();
setLayoutManager(new LayoutManagerImpl(context, mOrientation, mScrollSpeedPerInch));
setCalendarAdapter(new SimpleCalendarAdapter(context, new CalendarDataSet()));
}
示例7: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, @Nullable AttributeSet attrs) {
slidingLayoutList = new ArrayList<>();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlidingGroupLayout);
final int N = a.getIndexCount();
for (int i = 0; i < N; ++i) {
if (a.getIndex(i) == R.styleable.SlidingGroupLayout_independent_layouts) {
isIndependentGroup = a.getBoolean(a.getIndex(i), false);
}
}
}
示例8: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
mScaleTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mMaxVelocity = ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
//初始化滑动帮助类对象
//mScroller = new Scroller(context);
//右滑删除功能的开关,默认开
isSwipeEnable = true;
//IOS、QQ式交互,默认开
isIos = true;
//左滑右滑的开关,默认左滑打开菜单
isLeftSwipe = true;
TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SwipeMenuLayout, defStyleAttr, 0);
int count = ta.getIndexCount();
for (int i = 0; i < count; i++) {
int attr = ta.getIndex(i);
//如果引用成AndroidLib 资源都不是常量,无法使用switch case
if (attr == R.styleable.SwipeMenuLayout_swipeEnable) {
isSwipeEnable = ta.getBoolean(attr, true);
} else if (attr == R.styleable.SwipeMenuLayout_ios) {
isIos = ta.getBoolean(attr, true);
} else if (attr == R.styleable.SwipeMenuLayout_leftSwipe) {
isLeftSwipe = ta.getBoolean(attr, true);
}
}
ta.recycle();
}
示例9: 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.mContext = context;
this.mResources = context.getResources();
if (ANIMABLE) {
this.mNoteTextChangeListener = new NoteTextChangeListener();
}
final TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.Ui_InputLayout, defStyleAttr, defStyleRes);
for (int i = 0; i < attributes.getIndexCount(); i++) {
final int index = attributes.getIndex(i);
if (index == R.styleable.Ui_InputLayout_android_enabled) {
setEnabled(attributes.getBoolean(index, true));
} else if (index == R.styleable.Ui_InputLayout_android_minWidth) {
setMinimumWidth(attributes.getDimensionPixelSize(index, 0));
} else if (index == R.styleable.Ui_InputLayout_android_minHeight) {
setMinimumHeight(attributes.getDimensionPixelSize(index, 0));
} else if (index == R.styleable.Ui_InputLayout_android_label) {
setLabel(attributes.getText(index));
} else if (index == R.styleable.Ui_InputLayout_uiNote) {
setNote(attributes.getText(index));
} else if (index == R.styleable.Ui_InputLayout_uiNoteTextChangeDuration) {
this.mNoteTextChangeDuration = attributes.getInt(index, (int) mNoteTextChangeDuration);
} else if (index == R.styleable.Ui_InputLayout_uiInputFeatures) {
this.mFeatures = attributes.getInteger(index, mFeatures);
}
}
attributes.recycle();
this.ensureTintInfo();
int tintColor = Color.TRANSPARENT;
final Resources.Theme theme = context.getTheme();
if (theme != null) {
final TypedValue typedValue = new TypedValue();
if (theme.resolveAttribute(R.attr.colorControlActivated, typedValue, true)) {
tintColor = typedValue.data;
}
if (theme.resolveAttribute(R.attr.uiColorErrorHighlight, typedValue, true)) {
mColorsInfo.errorColors = ColorStateList.valueOf(typedValue.data);
}
}
mTintInfo.labelTint = TintManager.createLabelTintColors(getContext(), tintColor);
}
示例10: NineImageView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public NineImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NineImageView);
try {
for (int i = 0; i < a.getIndexCount(); i++) {
int attr = a.getIndex(i);
if (attr == R.styleable.NineImageView_nineImageHorizontalSpace) {
mHorizontalSpace = a.getDimensionPixelSize(attr, mHorizontalSpace);
} else if (attr == R.styleable.NineImageView_nineImageVerticalSpace) {
mVerticalSpace = a.getDimensionPixelSize(attr, mVerticalSpace);
} else if (attr == R.styleable.NineImageView_nineImageRadius) {
mRadius = a.getDimensionPixelSize(attr, mRadius);
} else if (attr == R.styleable.NineImageView_nineImageRatio) {
mRatio = a.getFloat(attr, mRatio);
}
}
} finally {
a.recycle();
}
}
mPaint.setAntiAlias(true);
mTextPaint.setAntiAlias(true);
mPlaceHolder = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_placeholder_image);
setImageUrls(null);
}
示例11: PraiseButton
import android.content.res.TypedArray; //导入方法依赖的package包/类
public PraiseButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.isPraised = false;
this.mContext = context;
init();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PraiseButton);
int N = a.getIndexCount();
for (int i = 0; i < N; i++) {
int attr = a.getIndex(i);
}
a.recycle();
}
示例12: handleAttrs
import android.content.res.TypedArray; //导入方法依赖的package包/类
void handleAttrs(@NonNull final TypedArray a) {
final int count = a.getIndexCount();
float minDotRadius = Defaults.DEFAULT_MIN_DOT_RADIUS;
float maxDotRadius = Defaults.DEFAULT_MAX_DOT_RADIUS;
for (int i = 0; i < count; i++) {
final int attr = a.getIndex(i);
if (attr == R.styleable.ParticlesView_minDotRadius) {
minDotRadius = a.getDimension(attr, Defaults.DEFAULT_MIN_DOT_RADIUS);
} else if (attr == R.styleable.ParticlesView_maxDotRadius) {
maxDotRadius = a.getDimension(attr, Defaults.DEFAULT_MAX_DOT_RADIUS);
} else if (attr == R.styleable.ParticlesView_lineThickness) {
setLineThickness(a.getDimension(attr, Defaults.DEFAULT_LINE_THICKNESS));
} else if (attr == R.styleable.ParticlesView_lineDistance) {
setLineDistance(a.getDimension(attr, Defaults.DEFAULT_LINE_DISTANCE));
} else if (attr == R.styleable.ParticlesView_numDots) {
setNumDots(a.getInteger(attr, Defaults.DEFAULT_DOT_NUMBER));
} else if (attr == R.styleable.ParticlesView_dotColor) {
setDotColor(a.getColor(attr, Defaults.DEFAULT_DOT_COLOR));
} else if (attr == R.styleable.ParticlesView_lineColor) {
setLineColor(a.getColor(attr, Defaults.DEFAULT_LINE_COLOR));
} else if (attr == R.styleable.ParticlesView_frameDelayMillis) {
setFrameDelay(a.getInteger(attr, Defaults.DEFAULT_DELAY));
} else if (attr == R.styleable.ParticlesView_stepMultiplier) {
setStepMultiplier(a.getFloat(attr, Defaults.DEFAULT_STEP_MULTIPLIER));
}
}
setDotRadiusRange(minDotRadius, maxDotRadius);
}
示例13: onProcessAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
*/
@Override
void onProcessAttributes(Context context, TypedArray attributes) {
super.onProcessAttributes(context, attributes);
final int n = attributes.getIndexCount();
for (int i = 0; i < n; i++) {
int index = attributes.getIndex(i);
if (index == R.styleable.Ui_GridView_uiRefreshEnabled) {
setRefreshEnabled(attributes.getBoolean(index, false));
} else if (index == R.styleable.Ui_GridView_uiRefreshGestureEnabled) {
setRefreshGestureEnabled(attributes.getBoolean(index, false));
}
}
}
示例14: WinkView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public WinkView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.WinkViewAttr, defStyleAttr, 0);
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
switch (attr) {
case R.styleable.WinkViewAttr_isOpen:
isOpen = a.getBoolean(attr, false);
Log.e(TAG, "WinkView: " + isOpen );
break;
default:
break;
}
}
a.recycle();
bgPaint = new Paint();
bgPaint.setAntiAlias(true);
bgPaint.setColor(Color.GRAY);
animator = new ValueAnimator();
animator.setDuration(200);
}
示例15: ClearableEditText
import android.content.res.TypedArray; //导入方法依赖的package包/类
public ClearableEditText(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater inflater = LayoutInflater.from(context);
mView = inflater.inflate(R.layout.clearable_edit_text, this);
mContext = context;
initViews();
// retrieved values correspond to the positions of the attributes
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ClearableEditText);
int count = typedArray.getIndexCount();
try {
for (int i = 0; i < count; ++i) {
int attr = typedArray.getIndex(i);
if (attr == R.styleable.ClearableEditText_android_hint) {
mHintText = typedArray.getString(attr);
setHintText(mHintText);
} else if (attr == R.styleable.ClearableEditText_android_inputType) {
mInputType = typedArray.getInt(attr, EditorInfo.TYPE_TEXT_VARIATION_NORMAL);
setInputType(mInputType);
} else if (attr == R.styleable.ClearableEditText_android_imeOptions) {
mImeOption = typedArray.getInt(attr, 0);
setImeOption(mImeOption);
} else if (attr == R.styleable.ClearableEditText_android_maxLines) {
mMaxLines = typedArray.getInt(attr, 1);
setMaxLines(mMaxLines);
} else if (attr == R.styleable.ClearableEditText_whiteClearButton) {
mWhiteClearButton = typedArray.getBoolean(attr, false);
}
}
setClearButtonEnabled(mWhiteClearButton);
}
// the recycle() will be executed obligatorily
finally {
// for reuse
typedArray.recycle();
}
}