本文整理了Java中android.util.AttributeSet.getAttributeCount()
方法的一些代码示例,展示了AttributeSet.getAttributeCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttributeSet.getAttributeCount()
方法的具体详情如下:
包路径:android.util.AttributeSet
类名称:AttributeSet
方法名:getAttributeCount
暂无
代码示例来源:origin: square/assertj-android
public AttributeSetAssert hasAttributeCount(int count) {
isNotNull();
int actualCount = actual.getAttributeCount();
assertThat(actualCount) //
.overridingErrorMessage("Expected attribute count <%s> but was <%s>.", count,
actualCount) //
.isEqualTo(count);
return this;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void attrsToTypedArray_shouldAllowMockedAttributeSets() throws Exception {
if (!useLegacy()) return;
AttributeSet mockAttributeSet = mock(AttributeSet.class);
when(mockAttributeSet.getAttributeCount()).thenReturn(1);
when(mockAttributeSet.getAttributeNameResource(0)).thenReturn(android.R.attr.windowBackground);
when(mockAttributeSet.getAttributeName(0)).thenReturn("android:windowBackground");
when(mockAttributeSet.getAttributeValue(0)).thenReturn("value");
resources.obtainAttributes(mockAttributeSet, new int[]{android.R.attr.windowBackground});
}
代码示例来源:origin: aa112901/remusic
protected static int[] extractStateSet(AttributeSet attrs) {
int j = 0;
final int numAttrs = attrs.getAttributeCount();
int[] states = new int[numAttrs];
for (int i = 0; i < numAttrs; i++) {
final int stateResId = attrs.getAttributeNameResource(i);
switch (stateResId) {
case 0:
break;
case android.R.attr.color:
case android.R.attr.alpha:
// Ignore attributes from StateListDrawableItem and
// AnimatedStateListDrawableItem.
continue;
default:
states[j++] = attrs.getAttributeBooleanValue(i, false)
? stateResId : -stateResId;
}
}
states = StateSet.trimStateSet(states, j);
return states;
}
}
代码示例来源:origin: aa112901/remusic
/**
* Extracts state_ attributes from an attribute set.
*
* @param attrs The attribute set.
* @return An array of state_ attributes.
*/
protected int[] extractStateSet(AttributeSet attrs) {
int j = 0;
final int numAttrs = attrs.getAttributeCount();
int[] states = new int[numAttrs];
for (int i = 0; i < numAttrs; i++) {
final int stateResId = attrs.getAttributeNameResource(i);
if (stateResId == 0) {
break;
} else if (stateResId == android.R.attr.drawable
|| stateResId == android.R.attr.id
|| stateResId == R.attr.drawableTint
|| stateResId == R.attr.drawableTintMode) {
// Ignore attributes from StateListDrawableItem and
// AnimatedStateListDrawableItem.
continue;
} else {
states[j++] = attrs.getAttributeBooleanValue(i, false)
? stateResId : -stateResId;
}
}
states = StateSet.trimStateSet(states, j);
return states;
}
代码示例来源:origin: fengjundev/Android-Skin-Loader
List<SkinAttr> viewAttrs = new ArrayList<SkinAttr>();
for (int i = 0; i < attrs.getAttributeCount(); i++){
String attrName = attrs.getAttributeName(i);
String attrValue = attrs.getAttributeValue(i);
代码示例来源:origin: jaydenxiao2016/AndroidFire
for (int i = 0; i < attrs.getAttributeCount(); i++) {
代码示例来源:origin: robolectric/robolectric
private AttributeResource findAttributeValue(int resId, AttributeSet attributeSet, Style styleAttrStyle, Style defStyleFromAttr, Style defStyleFromRes, @Nonnull Style themeStyleSet) {
if (attributeSet != null) {
for (int i = 0; i < attributeSet.getAttributeCount(); i++) {
if (attributeSet.getAttributeNameResource(i) == resId) {
String attributeValue;
代码示例来源:origin: GeekGhost/Ghost
public static int getAttributeValue(AttributeSet attr, int paramInt) {
int value = -1;
int count = attr.getAttributeCount();
for (int i = 0; i < count; i++) {
if (attr.getAttributeNameResource(i) == paramInt) {
String str = attr.getAttributeValue(i);
if (null != str && str.startsWith("?")) {
value = Integer.valueOf(str.substring(1, str.length())).intValue();
return value;
}
}
}
return value;
}
代码示例来源:origin: dongjunkun/GanK
public static int getAttributeValue(AttributeSet attr, int paramInt) {
int value = -1;
int count = attr.getAttributeCount();
for (int i = 0; i < count; i++) {
if (attr.getAttributeNameResource(i) == paramInt) {
String str = attr.getAttributeValue(i);
if (null != str && str.startsWith("?")) {
value = Integer.valueOf(str.substring(1, str.length())).intValue();
return value;
}
}
}
return value;
}
代码示例来源:origin: veryyoung/WechatLuckyMoney
public RangePreference(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.preference_range);
for (int i = 0; i < attrs.getAttributeCount(); i++) {
String attr = attrs.getAttributeName(i);
if (attr.equalsIgnoreCase("start")) {
startKey = attrs.getAttributeValue(i);
} else if (attr.equalsIgnoreCase("end")) {
endKey = attrs.getAttributeValue(i);
}
}
}
代码示例来源:origin: kongqw/OpenCVForAndroid
public CameraBridgeViewBase(Context context, AttributeSet attrs) {
super(context, attrs);
int count = attrs.getAttributeCount();
Log.d(TAG, "Attr count: " + Integer.valueOf(count));
TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false))
enableFpsMeter();
mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
getHolder().addCallback(this);
mMaxWidth = MAX_UNSPECIFIED;
mMaxHeight = MAX_UNSPECIFIED;
styledAttrs.recycle();
}
代码示例来源:origin: tz28/Chinese-number-gestures-recognition
public CameraBridgeViewBase(Context context, AttributeSet attrs) {
super(context, attrs);
int count = attrs.getAttributeCount();
Log.d(TAG, "Attr count: " + Integer.valueOf(count));
TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false))
enableFpsMeter();
mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
getHolder().addCallback(this);
mMaxWidth = MAX_UNSPECIFIED;
mMaxHeight = MAX_UNSPECIFIED;
styledAttrs.recycle();
}
代码示例来源:origin: DuckDeck/AndroidDemo
public CameraBridgeViewBase(Context context, AttributeSet attrs) {
super(context, attrs);
int count = attrs.getAttributeCount();
Log.d(TAG, "Attr count: " + Integer.valueOf(count));
TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false))
enableFpsMeter();
mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
getHolder().addCallback(this);
mMaxWidth = MAX_UNSPECIFIED;
mMaxHeight = MAX_UNSPECIFIED;
styledAttrs.recycle();
}
代码示例来源:origin: imistyrain/EasyPR4Android
public CameraBridgeViewBase(Context context, AttributeSet attrs) {
super(context, attrs);
int count = attrs.getAttributeCount();
Log.d(TAG, "Attr count: " + Integer.valueOf(count));
TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false))
enableFpsMeter();
mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
getHolder().addCallback(this);
mMaxWidth = MAX_UNSPECIFIED;
mMaxHeight = MAX_UNSPECIFIED;
styledAttrs.recycle();
}
代码示例来源:origin: KePeng1019/SmartPaperScan
public CameraBridgeViewBase(Context context, AttributeSet attrs) {
super(context, attrs);
int count = attrs.getAttributeCount();
Log.d(TAG, "Attr count: " + Integer.valueOf(count));
TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false))
enableFpsMeter();
mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
getHolder().addCallback(this);
mMaxWidth = MAX_UNSPECIFIED;
mMaxHeight = MAX_UNSPECIFIED;
styledAttrs.recycle();
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public AttributeSetAssert hasAttributeCount(int count) {
isNotNull();
int actualCount = actual.getAttributeCount();
assertThat(actualCount) //
.overridingErrorMessage("Expected attribute count <%s> but was <%s>.", count,
actualCount) //
.isEqualTo(count);
return this;
}
代码示例来源:origin: veryyoung/QQLuckyMoney
public SeekBarPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.preference_seekbar);
for (int i = 0; i < attrs.getAttributeCount(); i++) {
String attr = attrs.getAttributeName(i);
if (attr.equalsIgnoreCase("pref_kind")) {
prefKind = attrs.getAttributeValue(i);
break;
}
}
}
代码示例来源:origin: veryyoung/DingDingLuckyMoney
public SeekBarPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.preference_seekbar);
for (int i = 0; i < attrs.getAttributeCount(); i++) {
String attr = attrs.getAttributeName(i);
if (attr.equalsIgnoreCase("pref_kind")) {
prefKind = attrs.getAttributeValue(i);
break;
}
}
}
代码示例来源:origin: hamidness/restring
private AttributeSet getAttributeSet(boolean withAppPrefix) {
AttributeSet attributeSet = Mockito.mock(AttributeSet.class);
when(attributeSet.getAttributeCount()).thenReturn(TITLE_ATTR_INDEX + 2);
when(attributeSet.getAttributeName(anyInt())).thenReturn("other_attribute");
when(attributeSet.getAttributeName(TITLE_ATTR_INDEX)).thenReturn((withAppPrefix ? "app:" : "") + TITLE_ATTR_KEY);
when(attributeSet.getAttributeValue(TITLE_ATTR_INDEX)).thenReturn("@" + TITLE_RES_ID);
when(attributeSet.getAttributeResourceValue(eq(TITLE_ATTR_INDEX), anyInt())).thenReturn(TITLE_RES_ID);
return attributeSet;
}
}
代码示例来源:origin: hamidness/restring
private AttributeSet getAttributeSet(boolean withAndroidPrefix) {
AttributeSet attributeSet = Mockito.mock(AttributeSet.class);
when(attributeSet.getAttributeCount()).thenReturn(TITLE_ATTR_INDEX + 2);
when(attributeSet.getAttributeName(anyInt())).thenReturn("other_attribute");
when(attributeSet.getAttributeName(TITLE_ATTR_INDEX)).thenReturn((withAndroidPrefix ? "android:" : "") + TITLE_ATTR_KEY);
when(attributeSet.getAttributeValue(TITLE_ATTR_INDEX)).thenReturn("@" + TITLE_RES_ID);
when(attributeSet.getAttributeResourceValue(eq(TITLE_ATTR_INDEX), anyInt())).thenReturn(TITLE_RES_ID);
return attributeSet;
}
}
内容来源于网络,如有侵权,请联系作者删除!