本文整理了Java中android.util.AttributeSet.getAttributeName()
方法的一些代码示例,展示了AttributeSet.getAttributeName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttributeSet.getAttributeName()
方法的具体详情如下:
包路径:android.util.AttributeSet
类名称:AttributeSet
方法名:getAttributeName
暂无
代码示例来源: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: jaydenxiao2016/AndroidFire
if (attrs.getAttributeName(i).equals(ATTR_BACKGROUND)) {
mBackGroundViews.add(new AttrEntity<View>(view,getAttr(mClass,attrs.getAttributeValue(i))));
if (attrs.getAttributeName(i).equals(ATTR_TEXTCOLOR)) {
mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
if (attrs.getAttributeName(i).equals(ATTR_TWO_TEXTCOLOR)) {
mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
if (attrs.getAttributeName(i).equals(ATTR_THREE_TEXTCOLOR)) {
mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
if (attrs.getAttributeName(i).equals(ATTR_BACKGROUND_DRAWABLE)) {
mBackGroundDrawableViews.add(new AttrEntity<View>(view,getAttr(mClass,attrs.getAttributeValue(i))));
代码示例来源:origin: fengjundev/Android-Skin-Loader
String attrName = attrs.getAttributeName(i);
String attrValue = attrs.getAttributeValue(i);
代码示例来源: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: 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: robolectric/robolectric
ResName resName = ResName.qualifyResName(attributeSet.getAttributeName(i), defaultPackageName, "attr");
Integer referenceResId = null;
if (AttributeResource.isResourceReference(attributeValue)) {
代码示例来源:origin: stackoverflow.com
public MyEditText(Context context, AttributeSet attrs) {
super(context, attrs);
Log.i("attribute name at index 0", attrs.getAttributeName(0));
}
代码示例来源:origin: NightscoutFoundation/xDrip
public ColorPicker(Context context, AttributeSet attrs) {
super(context, attrs);
if (attrs != null) {
for (int i = 0; i < attrs.getAttributeCount(); i++) {
if (attrs.getAttributeName(i).equals("defaultValue")) {
final String this_value = attrs.getAttributeValue(i);
if (this_value.length() > 0) {
if (debug)
Log.d(TAG, "Attribute debug: " + i + " " + attrs.getAttributeName(i) + " " + this_value);
if (this_value.startsWith("@")) {
localDefaultValue = Color.parseColor(getStringResourceByName(this_value));
} else {
localDefaultValue = Color.parseColor(this_value);
}
localDefaultValue = Color.parseColor(attrs.getAttributeValue(i));
super.defaultColor = localDefaultValue;
} else {
Log.w(TAG, "No default value for colorpicker");
}
break;
}
}
}
}
代码示例来源: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
@Override
public View transform(View view, AttributeSet attrs) {
if (view == null || !getViewType().isInstance(view)) {
return view;
}
Resources resources = view.getContext().getResources();
for (int index = 0; index < attrs.getAttributeCount(); index++) {
String attributeName = attrs.getAttributeName(index);
switch (attributeName) {
case ATTRIBUTE_APP_TITLE:
case ATTRIBUTE_TITLE: {
String value = attrs.getAttributeValue(index);
if (value != null && value.startsWith("@")) {
setTitleForView(view, resources.getString(attrs.getAttributeResourceValue(index, 0)));
}
break;
}
}
}
return view;
}
代码示例来源:origin: org.metawidget.modules/metawidget-all
public Stub( Context context, AttributeSet attributes ) {
super( context, attributes );
setTag( attributes.getAttributeValue( null, "tag" ) );
// For each attribute...
for ( int loop = 0, length = attributes.getAttributeCount(); loop < length; loop++ ) {
// ...that looks like a stub attribute...
String name = attributes.getAttributeName( loop );
if ( !name.startsWith( ATTRIBUTE_PREFIX ) ) {
continue;
}
name = name.substring( ATTRIBUTE_PREFIX.length() );
if ( !Character.isUpperCase( name.charAt( 0 ) ) ) {
continue;
}
// ...remember it
String value = attributes.getAttributeValue( loop );
setAttribute( StringUtils.decapitalize( name ), value );
}
}
代码示例来源:origin: neopixl/PixlUI
/**
* XML methods
*
* @param ctx
* @param attrs
*/
@SuppressLint("NewApi")
private void setAllCaps(Context ctx, AttributeSet attrs) {
if (!isInEditMode()) {
int indexSize = attrs.getAttributeCount();
boolean allCaps = false;
for (int i = 0; i < indexSize; i++) {
if (attrs.getAttributeName(i).equals(
RADIOBUTTON_OS_ATTRIBUTE_TEXT_ALL_CAPS)) {
allCaps = attrs.getAttributeBooleanValue(i, false);
break;
}
}
if (allCaps) {
setAllCaps(allCaps);
}
}
}
代码示例来源: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: achenglike/NightModel
public static List<Attr> getNightModelAttr(Object[] args, Resources resources) {
List<Attr> nightModelAttrs = new ArrayList<>();
if (args != null && args.length > 0) {
for (Object obj: args) {
if (obj instanceof AttributeSet) {
AttributeSet attrs = (AttributeSet) obj;
for (int i = 0; i < attrs.getAttributeCount(); i++)
{
String attrName = attrs.getAttributeName(i);
String attrValue = attrs.getAttributeValue(i);
AttrType attrType = getSupportAttrType(attrName);
if (attrType == null) continue;
if (attrValue.startsWith("@")) {
String resourceName = attrType.getResourceName(attrValue, resources);
Attr attr = new Attr(resourceName, attrType);
nightModelAttrs.add(attr);
}
}
}
}
}
return nightModelAttrs;
}
}
代码示例来源: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;
}
}
代码示例来源:origin: neopixl/PixlUI
/**
* XML methods
*
* @param ctx
* @param attrs
*/
private void setAllCaps(Context ctx, AttributeSet attrs) {
if (!isInEditMode()) {
int indexSize = attrs.getAttributeCount();
boolean allCaps = false;
for (int i = 0; i < indexSize; i++) {
if (attrs.getAttributeName(i).equals(
BUTTON_OS_ATTRIBUTE_TEXT_ALL_CAPS)) {
allCaps = attrs.getAttributeBooleanValue(i, false);
break;
}
}
if (allCaps) {
setAllCaps(allCaps);
}
}
}
代码示例来源:origin: hamidness/restring
private AttributeSet getAttributeSet(boolean withAndroidPrefix) {
AttributeSet attributeSet = Mockito.mock(AttributeSet.class);
when(attributeSet.getAttributeCount()).thenReturn(TEXT_ATTR_INDEX + 2);
when(attributeSet.getAttributeName(anyInt())).thenReturn("other_attribute");
when(attributeSet.getAttributeName(TEXT_ATTR_INDEX)).thenReturn((withAndroidPrefix ? "android:" : "") + TEXT_ATTR_KEY);
when(attributeSet.getAttributeValue(TEXT_ATTR_INDEX)).thenReturn("@" + TEXT_RES_ID);
when(attributeSet.getAttributeResourceValue(eq(TEXT_ATTR_INDEX), anyInt())).thenReturn(TEXT_RES_ID);
when(attributeSet.getAttributeName(HINT_ATTR_INDEX)).thenReturn((withAndroidPrefix ? "android:" : "") + HINT_ATTR_KEY);
when(attributeSet.getAttributeValue(HINT_ATTR_INDEX)).thenReturn("@" + HINT_RES_ID);
when(attributeSet.getAttributeResourceValue(eq(HINT_ATTR_INDEX), anyInt())).thenReturn(HINT_RES_ID);
return attributeSet;
}
}
代码示例来源:origin: neopixl/PixlUI
/**
* XML methods
*
* @param ctx
* @param attrs
*/
private void setAllCaps(Context ctx, AttributeSet attrs) {
if (!isInEditMode()) {
int indexSize = attrs.getAttributeCount();
boolean allCaps = false;
for (int i = 0; i < indexSize; i++) {
if (attrs.getAttributeName(i).equals(
EDITTEXT_OS_ATTRIBUTE_TEXT_ALL_CAPS)) {
allCaps = attrs.getAttributeBooleanValue(i, false);
break;
}
}
if (allCaps && !isInEditMode()) {
setAllCaps(allCaps);
}
}
}
代码示例来源:origin: luhaoaimama1/zone-sdk
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
sout("name=" + name + "----open");
int n = attrs.getAttributeCount();
for (int i = 0; i < n; i++) {
sout("AttributeName:" + attrs.getAttributeName(i));
sout("AttributeValue:" + attrs.getAttributeValue(i));
}
if (name.equals("TextView")) {
Button button = new Button(context, attrs);
return button;
}
sout("-------------end");
return null;
}
});
内容来源于网络,如有侵权,请联系作者删除!