android.util.AttributeSet.getAttributeBooleanValue()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中android.util.AttributeSet.getAttributeBooleanValue()方法的一些代码示例,展示了AttributeSet.getAttributeBooleanValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttributeSet.getAttributeBooleanValue()方法的具体详情如下:
包路径:android.util.AttributeSet
类名称:AttributeSet
方法名:getAttributeBooleanValue

AttributeSet.getAttributeBooleanValue介绍

暂无

代码示例

代码示例来源:origin: qiujuer/Genius-Android

/**
 * Get the attribute have enabled value
 * Form android styles namespace
 *
 * @param attrs        AttributeSet
 * @param attribute    The attribute to retrieve
 * @param defaultValue What to return if the attribute isn't found
 * @return Resulting value
 */
public static boolean isTrueFromAttribute(AttributeSet attrs, String attribute, boolean defaultValue) {
  return attrs.getAttributeBooleanValue(Ui.androidStyleNameSpace, attribute, defaultValue);
}

代码示例来源:origin: ankidroid/Anki-Android

private boolean getAllowEmptyFromAttributes(AttributeSet attrs) {
    if (attrs == null) {
      return true;
    }
    return attrs.getAttributeBooleanValue(AnkiDroidApp.XML_CUSTOM_NAMESPACE, "allowEmpty", true);
  }
}

代码示例来源:origin: fengjundev/Android-Skin-Loader

@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
  // if this is NOT enable to be skined , simplly skip it 
  boolean isSkinEnable = attrs.getAttributeBooleanValue(SkinConfig.NAMESPACE, SkinConfig.ATTR_SKIN_ENABLE, false);
  if (!isSkinEnable){
      return null;
  }
  
  View view = createView(context, name, attrs);
  
  if (view == null){
    return null;
  }
  
  parseSkinAttr(context, attrs, view);
  
  return view;
}

代码示例来源:origin: navasmdc/MaterialDesignLibrary

public Button(Context context, AttributeSet attrs) {
  super(context, attrs);
  setDefaultProperties();
  clickAfterRipple = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,
      "animate", true);
  setAttributes(attrs);
  beforeBackground = backgroundColor;
  if (rippleColor == null)
    rippleColor = makePressColor();
}

代码示例来源: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: robolectric/robolectric

@Test
public void getAttributeValue_byName_shouldReturnValueFromAttribute() throws Exception {
 AttributeSet roboAttributeSet = Robolectric.buildAttributeSet()
   .addAttribute(R.attr.isSugary, "oh heck yeah")
   .build();
 assertThat(roboAttributeSet.getAttributeValue(APP_NS, "isSugary"))
   .isEqualTo("false");
 assertThat(roboAttributeSet.getAttributeBooleanValue(APP_NS, "isSugary", true))
   .isEqualTo(false);
 assertThat(roboAttributeSet.getAttributeBooleanValue(APP_NS, "animalStyle", true))
   .isEqualTo(true);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getAttributeBooleanValue_shouldReturnDefaultBooleanValueWhenNotInAttributeSet() throws Exception {
 AttributeSet roboAttributeSet =  Robolectric.buildAttributeSet()
   .build();
 assertThat(roboAttributeSet.getAttributeBooleanValue(ANDROID_RES_NS_PREFIX + "com.some.namespace", "isSugary", true))
   .isTrue();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getAttributeBooleanValue_shouldGetBooleanValuesFromAttributes() throws Exception {
 AttributeSet roboAttributeSet = Robolectric.buildAttributeSet()
   .addAttribute(R.attr.isSugary, "true")
   .build();
 assertThat(roboAttributeSet.getAttributeBooleanValue(APP_NS, "isSugary", false))
   .isTrue();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getAttributeBooleanValue_withNamespace_shouldGetBooleanValuesFromAttributes() throws Exception {
 // org.robolectric.lib1.R values should be reconciled to match org.robolectric.R values.
 AttributeSet roboAttributeSet = Robolectric.buildAttributeSet()
   .addAttribute(R.attr.isSugary, "true")
   .build();
 assertThat(roboAttributeSet.getAttributeBooleanValue(APP_NS, "isSugary", false)).isTrue();
}

代码示例来源:origin: navasmdc/MaterialDesignLibrary

final boolean check = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,
    "check", false);
  post(new Runnable() {

代码示例来源:origin: navasmdc/MaterialDesignLibrary

if(iconResource != -1)
  drawableIcon = getResources().getDrawable(iconResource);
final boolean animate = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"animate", false);
  post(new Runnable() {

代码示例来源:origin: navasmdc/MaterialDesignLibrary

protected void setAttributes(AttributeSet attrs) {
  setBackgroundResource(R.drawable.background_transparent);
  // Set size of view
  setMinimumHeight(Utils.dpToPx(48, getResources()));
  setMinimumWidth(Utils.dpToPx(80, getResources()));
  // Set background Color
  // Color by resource
  int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,
      "background", -1);
  if (bacgroundColor != -1) {
    setBackgroundColor(getResources().getColor(bacgroundColor));
  } else {
    // Color by hexadecimal
    int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
    if (background != -1)
      setBackgroundColor(background);
  }
  check = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "check",
      false);
  eventCheck = check;
  ball = new Ball(getContext());
  RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20,
      getResources()), Utils.dpToPx(20, getResources()));
  params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
  ball.setLayoutParams(params);
  addView(ball);
}

代码示例来源:origin: navasmdc/MaterialDesignLibrary

showNumberIndicator = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,
    "showNumberIndicator", false);
min = attrs.getAttributeIntValue(MATERIALDESIGNXML, "min", 0);

代码示例来源:origin: ukanth/afwall

private void init(Context context, AttributeSet attrs) {
  mDensity = getContext().getResources().getDisplayMetrics().density;
  setOnPreferenceClickListener(this);
  if (attrs != null) {
    mAlphaSliderEnabled = attrs.getAttributeBooleanValue(null, "alphaSlider", false);
    mHexValueEnabled = attrs.getAttributeBooleanValue(null, "hexValue", false);
  }
}

代码示例来源:origin: qqliu10u/QSkinLoader

public boolean isSupportSkin(String name, Context context, AttributeSet attrs) {
  //只有View设置了skin:enable,才解析属性
  boolean isSkinEnable = attrs.getAttributeBooleanValue(
      SkinConstant.XML_NAMESPACE,
      SkinConstant.ATTR_SKIN_ENABLE,
      false);
  return isSkinEnable;
}

代码示例来源:origin: wasdennnoch/AndroidN-ify

private void init(Context context, AttributeSet attrs) {
  mDensity = getContext().getResources().getDisplayMetrics().density;
  setOnPreferenceClickListener(this);
  if (attrs != null) {
    mAlphaSliderEnabled = attrs.getAttributeBooleanValue(null, "alphaSlider", false);
    mHexValueEnabled = attrs.getAttributeBooleanValue(null, "hexValue", false);
  }
}

代码示例来源:origin: corcoran/Hangar

private void init(Context context, AttributeSet attrs) {
  mDensity = getContext().getResources().getDisplayMetrics().density;
  setOnPreferenceClickListener(this);
  if (attrs != null) {
    mAlphaSliderEnabled = attrs.getAttributeBooleanValue(null, "alphaSlider", false);
    mHexValueEnabled = attrs.getAttributeBooleanValue(null, "hexValue", false);
  }
}

代码示例来源:origin: arminha/worldclockwidget

private void init(Context context, AttributeSet attrs) {
  mDensity = getContext().getResources().getDisplayMetrics().density;
  setOnPreferenceClickListener(this);
  if (attrs != null) {
    mAlphaSliderEnabled = attrs.getAttributeBooleanValue(null, "alphaSlider", false);
  }
}

代码示例来源:origin: com.github.japgolly.android.test/robolectric

public void applyFocus() {
  if (noParentHasFocus(realView)) {
    Boolean focusRequested = attributeSet.getAttributeBooleanValue("android", "focus", false);
    if (focusRequested || realView.isFocusableInTouchMode()) {
      realView.requestFocus();
    }
  }
}

相关文章