本文整理了Java中android.util.AttributeSet.getAttributeNameResource()
方法的一些代码示例,展示了AttributeSet.getAttributeNameResource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttributeSet.getAttributeNameResource()
方法的具体详情如下:
包路径:android.util.AttributeSet
类名称:AttributeSet
方法名:getAttributeNameResource
暂无
代码示例来源: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: 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
/**
* 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: robolectric/robolectric
@Test
public void shouldReturnAttributesInOrderOfNameResId() throws Exception {
AttributeSet roboAttributeSet = Robolectric.buildAttributeSet()
.addAttribute(android.R.attr.height, "1px")
.addAttribute(R.attr.animalStyle, "meow")
.addAttribute(android.R.attr.width, "1px")
.build();
assertThat(asList(
roboAttributeSet.getAttributeName(0),
roboAttributeSet.getAttributeName(1),
roboAttributeSet.getAttributeName(2)
)).containsExactly("height", "width", "animalStyle");
assertThat(asList(
roboAttributeSet.getAttributeNameResource(0),
roboAttributeSet.getAttributeNameResource(1),
roboAttributeSet.getAttributeNameResource(2)
)).containsExactly(android.R.attr.height, android.R.attr.width, R.attr.animalStyle);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getAttributeNameResource() throws Exception {
AttributeSet roboAttributeSet = Robolectric.buildAttributeSet()
.addAttribute(R.attr.aspectRatio, "1")
.build();
assertThat(roboAttributeSet.getAttributeNameResource(0))
.isEqualTo(R.attr.aspectRatio);
}
代码示例来源: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;
try {
代码示例来源: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: 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: ExcaliburZ/ImitateBilibili
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: MCMrARM/revolution-irc
int[] stateSpec = new int[numAttrs];
for (int i = 0; i < numAttrs; i++) {
final int stateResId = attrs.getAttributeNameResource(i);
switch (stateResId) {
case android.R.attr.color:
代码示例来源:origin: org.robolectric/shadows-core-v23
private AttributeResource findAttributeValue(int resId, AttributeSet attributeSet, Style styleAttrStyle, Style defStyleFromAttr, Style defStyleFromRes, @NotNull Style themeStyleSet) {
if (attributeSet != null) {
for (int i = 0; i < attributeSet.getAttributeCount(); i++) {
if (attributeSet.getAttributeNameResource(i) == resId && attributeSet.getAttributeValue(i) != null) {
ResName resName = resourceLoader.getResourceIndex().getResName(resId);
代码示例来源:origin: org.robolectric/framework
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 && attributeSet.getAttributeValue(i) != null) {
String defaultPackageName = ResourceIds.isFrameworkResource(resId) ? "android" : RuntimeEnvironment.application.getPackageName();
ResName resName = ResName.qualifyResName(attributeSet.getAttributeName(i), defaultPackageName, "attr");
代码示例来源:origin: org.robolectric/shadows-core
private AttributeResource findAttributeValue(int resId, AttributeSet attributeSet, Style styleAttrStyle, Style defStyleFromAttr, Style defStyleFromRes, @NotNull Style themeStyleSet) {
if (attributeSet != null) {
for (int i = 0; i < attributeSet.getAttributeCount(); i++) {
if (attributeSet.getAttributeNameResource(i) == resId && attributeSet.getAttributeValue(i) != null) {
String defaultPackageName = ResourceIds.isFrameworkResource(resId) ? "android" : RuntimeEnvironment.application.getPackageName();
ResName resName = ResName.qualifyResName(attributeSet.getAttributeName(i), defaultPackageName, "attr");
代码示例来源:origin: org.robolectric/shadows-framework
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;
try {
内容来源于网络,如有侵权,请联系作者删除!