本文整理汇总了Java中android.util.AttributeSet.getAttributeIntValue方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet.getAttributeIntValue方法的具体用法?Java AttributeSet.getAttributeIntValue怎么用?Java AttributeSet.getAttributeIntValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.AttributeSet
的用法示例。
在下文中一共展示了AttributeSet.getAttributeIntValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: existAttributeIntValue
import android.util.AttributeSet; //导入方法依赖的package包/类
/**
* Check whether android {@code attribute} exists and is set in {@code attributeSet}
* @param attrs {@code AttributeSet} where the {@code attribute} is included (if that is set)
* @param namespace Namespace where the {@code attribute} is defined
* @param attribute Attribute to be checked
* @param invalidValue The flag to check that the {@code attribute} is set
* @return true if the {@code attribute} exists
*/
@Deprecated
public static boolean existAttributeIntValue(AttributeSet attrs, String namespace, String attribute, int invalidValue) {
// If attrs is null, assume the attribute is not set.
if ( attrs == null ) {
return false;
}
Assert.notNull(attrs, "namespace");
Assert.notNull(attrs, "attribute");
boolean isExist = true;
int value = attrs.getAttributeIntValue(namespace, attribute, invalidValue);
if ( value == invalidValue ) {
isExist = false;
}
return isExist;
}
示例2: CalculatorDisplay
import android.util.AttributeSet; //导入方法依赖的package包/类
public CalculatorDisplay(Context context, AttributeSet attrs) {
super(context, attrs);
mMaxDigits = attrs.getAttributeIntValue(null, ATTR_MAX_DIGITS, DEFAULT_MAX_DIGITS);
String sinString = context.getString(R.string.sin);
String cosString = context.getString(R.string.cos);
String tanString = context.getString(R.string.tan);
String arcsinString = context.getString(R.string.arcsin);
String arccosString = context.getString(R.string.arccos);
String arctanString = context.getString(R.string.arctan);
String logString = context.getString(R.string.lg);
String lnString = context.getString(R.string.ln);
String modString = context.getString(R.string.mod);
String dx = context.getString(R.string.dx);
String dy = context.getString(R.string.dy);
keywords = Arrays.asList(sinString + "(", cosString + "(", tanString + "(",
arcsinString.replace(EquationFormatter.POWER, EquationFormatter.PLACEHOLDER) + "(",
arccosString.replace(EquationFormatter.POWER, EquationFormatter.PLACEHOLDER) + "(",
arctanString.replace(EquationFormatter.POWER, EquationFormatter.PLACEHOLDER) + "(", logString + "(", modString + "(", lnString + "(", dx, dy);
setOnLongClickListener(this);
}
示例3: GraphGLView
import android.util.AttributeSet; //导入方法依赖的package包/类
/**
* Create a GraphGL view, set a renderer to show the configured duration to time.
*/
public GraphGLView(Context context, AttributeSet attrs) {
super(context, attrs);
// OpenGL 2.0
setEGLContextClientVersion(2);
int durationSec = DEFAULT_DURATION_SEC;
for (int i = 0; i < attrs.getAttributeCount(); i++) {
if ("durationSec".equals(attrs.getAttributeName(i))) {
durationSec = attrs.getAttributeIntValue(i, DEFAULT_DURATION_SEC);
}
}
this.renderer = new GraphGLRenderer(this.getContext(), durationSec);
setRenderer(this.renderer);
}
示例4: setValuesFromXml
import android.util.AttributeSet; //导入方法依赖的package包/类
private void setValuesFromXml(AttributeSet attrs) {
mMaxValue = attrs.getAttributeIntValue(ANDROIDNS, "max", 100);
mMinValue = attrs.getAttributeIntValue(ROBOBUNNYNS, "min", 0);
mUnitsLeft = getAttributeStringValue(attrs, ROBOBUNNYNS, "unitsLeft", "");
String units = getAttributeStringValue(attrs, ROBOBUNNYNS, "units", "");
mUnitsRight = getAttributeStringValue(attrs, ROBOBUNNYNS, "unitsRight", units);
try {
String newInterval = attrs.getAttributeValue(ROBOBUNNYNS, "interval");
if(newInterval != null)
mInterval = Integer.parseInt(newInterval);
}
catch(Exception e) {
Log.e(TAG, "Invalid interval value", e);
}
}
示例5: init
import android.util.AttributeSet; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
if (attrs != null) {
final int scaleTypeIndex = attrs.getAttributeIntValue(
GifViewUtils.ANDROID_NS, "scaleType", -1);
if (scaleTypeIndex >= 0 && scaleTypeIndex < sScaleTypeArray.length) {
mScaleType = sScaleTypeArray[scaleTypeIndex];
}
final TypedArray textureViewAttributes = getContext()
.obtainStyledAttributes(attrs, R.styleable.GifTextureView,
defStyleAttr, defStyleRes);
mInputSource = findSource(textureViewAttributes);
super.setOpaque(textureViewAttributes.getBoolean(R.styleable.GifTextureView_isOpaque, false));
textureViewAttributes.recycle();
mFreezesAnimation = GifViewUtils.isFreezingAnimation(this, attrs,
defStyleAttr, defStyleRes);
} else {
super.setOpaque(false);
}
if (!isInEditMode()) {
mRenderThread = new RenderThread();
if (mInputSource != null) {
mRenderThread.start();
}
}
}
示例6: SeekBarPreference
import android.util.AttributeSet; //导入方法依赖的package包/类
public SeekBarPreference(Context context, AttributeSet attrs) {
super(context, attrs);
if (attrs != null) {
mMinimum = attrs.getAttributeIntValue(null, "minimum", 0);
mMaximum = attrs.getAttributeIntValue(null, "maximum", 100);
mInterval = attrs.getAttributeIntValue(null, "interval", 1);
mDefaultValue = mMinimum;
mMonitorBoxEnabled = attrs.getAttributeBooleanValue(null, "monitorBoxEnabled", false);
mMonitorBoxUnit = attrs.getAttributeValue(null, "monitorBoxUnit");
}
mHandler = new Handler();
}
示例7: loadValuesFromXml
import android.util.AttributeSet; //导入方法依赖的package包/类
void loadValuesFromXml(AttributeSet attrs) {
if(attrs == null) {
currentValue = DEFAULT_CURRENT_VALUE;
minValue = DEFAULT_MIN_VALUE;
maxValue = DEFAULT_MAX_VALUE;
interval = DEFAULT_INTERVAL;
dialogEnabled = DEFAULT_DIALOG_ENABLED;
isEnabled = DEFAULT_IS_ENABLED;
}
else {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SeekBarPreference);
try {
minValue = a.getInt(R.styleable.SeekBarPreference_msbp_minValue, DEFAULT_MIN_VALUE);
maxValue = a.getInt(R.styleable.SeekBarPreference_msbp_maxValue, DEFAULT_MAX_VALUE);
interval = a.getInt(R.styleable.SeekBarPreference_msbp_interval, DEFAULT_INTERVAL);
dialogEnabled = a.getBoolean(R.styleable.SeekBarPreference_msbp_dialogEnabled, DEFAULT_DIALOG_ENABLED);
measurementUnit = a.getString(R.styleable.SeekBarPreference_msbp_measurementUnit);
currentValue = attrs.getAttributeIntValue("http://schemas.android.com/apk/res/android", "defaultValue", DEFAULT_CURRENT_VALUE);
// dialogStyle = a.getInt(R.styleable.SeekBarPreference_msbp_interval, DEFAULT_DIALOG_STYLE);
dialogStyle = DEFAULT_DIALOG_STYLE;
if(isView) {
title = a.getString(R.styleable.SeekBarPreference_msbp_view_title);
summary = a.getString(R.styleable.SeekBarPreference_msbp_view_summary);
currentValue = a.getInt(R.styleable.SeekBarPreference_msbp_view_defaultValue, DEFAULT_CURRENT_VALUE);
isEnabled = a.getBoolean(R.styleable.SeekBarPreference_msbp_view_enabled, DEFAULT_IS_ENABLED);
}
}
finally {
a.recycle();
}
}
}
示例8: SeekBarPreference
import android.util.AttributeSet; //导入方法依赖的package包/类
public SeekBarPreference(Context aContext, AttributeSet attrs) {
super(aContext, attrs);
context = aContext;
dialogMessage = attrs.getAttributeValue(ANDROID_NS, "dialogMessage");
suffix = attrs.getAttributeValue(ANDROID_NS, "text");
defaultValue = attrs.getAttributeFloatValue(ANDROID_NS, "defaultValue", 0.0f);
max = attrs.getAttributeIntValue(ANDROID_NS, "max", 10);
}
示例9: SeekBarPreference
import android.util.AttributeSet; //导入方法依赖的package包/类
public SeekBarPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mSuffix = attrs.getAttributeValue(ANDROID_NS, "text");
mDefault = attrs.getAttributeIntValue(ANDROID_NS, "defaultValue",
Constants.DEFAULT_TEXT_SIZE);
mMax = attrs.getAttributeIntValue(ANDROID_NS, "max", 100);
setLayoutResource(R.layout.seekbar_pref);
mTintColor = ContextCompat.getColor(context, R.color.accent_color);
}
示例10: setAttributes
import android.util.AttributeSet; //导入方法依赖的package包/类
@Override
protected void setAttributes(AttributeSet attrs) {
super.setAttributes(attrs);
if (!isInEditMode()) {
getBackground().setAlpha(0);
}
showNumberIndicator = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"showNumberIndicator", false);
min = attrs.getAttributeIntValue(MATERIALDESIGNXML, "min", 0);
max = attrs.getAttributeIntValue(MATERIALDESIGNXML, "max", 100);// max > min
value = attrs.getAttributeIntValue(MATERIALDESIGNXML, "value", min);
float size = 20;
String thumbSize = attrs.getAttributeValue(MATERIALDESIGNXML, "thumbSize");
if (thumbSize != null) {
size = Utils.dipOrDpToFloat(thumbSize);
}
ball = new Ball(getContext());
setBallParams(size);
addView(ball);
// Set if slider content number indicator
if (showNumberIndicator) {
if (!isInEditMode()) {
numberIndicator = new NumberIndicator(getContext());
}
}
}
示例11: setBackgroundAttributes
import android.util.AttributeSet; //导入方法依赖的package包/类
/**
* 设置背景色
* Set background Color
*/
protected void setBackgroundAttributes(AttributeSet attrs) {
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 && !isInEditMode()) {
setBackgroundColor(background);
}else {
setBackgroundColor(backgroundColor);// 如果没有设置,就用这个颜色
}
}
}
示例12: setRippleAttributes
import android.util.AttributeSet; //导入方法依赖的package包/类
protected void setRippleAttributes(AttributeSet attrs) {
/**
* 初始化按压时涟漪的颜色
* Set Ripple Color
* Color by resource
*/
int color = attrs.getAttributeResourceValue(MATERIALDESIGNXML,"rippleColor",-1);
if(color != -1){
rippleColor = getResources().getColor(color);
settedRippleColor = true;
}else{
// Color by hexadecimal
int rColor = attrs.getAttributeIntValue(MATERIALDESIGNXML, "rippleColor", -1);// 16进制的颜色
if(rColor != -1 && !isInEditMode()) {
rippleColor = rColor;
settedRippleColor = true;
}
}
/**
* 初始化涟漪扩展的速度
* init Ripple speed
*/
rippleSpeed = attrs.getAttributeFloatValue(MATERIALDESIGNXML, "rippleSpeed", rippleSpeed);
/**
* 设定涟漪的响应时间
*/
clickAfterRipple = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "clickAfterRipple", clickAfterRipple);
}
示例13: DialogPreferenceSeekBar
import android.util.AttributeSet; //导入方法依赖的package包/类
public DialogPreferenceSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
// Get attributes from preferences xml
mDefault = attrs.getAttributeIntValue(ANDROID_NS, "defaultValue", DEFAULT_VALUE);
mMax = attrs.getAttributeIntValue(ANDROID_NS, "max", DEFAULT_MAX);
mValue = DEFAULT_VALUE;
}
示例14: setAttributes
import android.util.AttributeSet; //导入方法依赖的package包/类
protected void setAttributes(AttributeSet attrs) {
setBackgroundResource(R.drawable.background_transparent);
// Set size of view
setMinimumHeight(dpToPx(48, getResources()));
setMinimumWidth(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);
}
min = attrs.getAttributeIntValue(MATERIALDESIGNXML, "min", 0);
max = attrs.getAttributeIntValue(MATERIALDESIGNXML, "max", 0);
value = attrs.getAttributeIntValue(MATERIALDESIGNXML, "value", min);
ball = new Ball(getContext());
LayoutParams params = new LayoutParams(dpToPx(15, getResources()), dpToPx(15, getResources()));
params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
ball.setLayoutParams(params);
addView(ball);
}
示例15: setAttributes
import android.util.AttributeSet; //导入方法依赖的package包/类
@Override
protected void setAttributes(AttributeSet attrs) {
// Set text button
String text = null;
int textResource = attrs.getAttributeResourceValue(ANDROIDXML,"text",-1);
if(textResource != -1){
text = getResources().getString(textResource);
}else{
text = attrs.getAttributeValue(ANDROIDXML,"text");
}
if(text != null){
textButton = new TextView(getContext());
textButton.setText(text.toUpperCase());
textButton.setTextColor(backgroundColor);
textButton.setTypeface(null, Typeface.BOLD);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
textButton.setLayoutParams(params);
addView(textButton);
}
int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1);
if(bacgroundColor != -1){
setBackgroundColor(getResources().getColor(bacgroundColor));
}else{
// Color by hexadecimal
// Color by hexadecimal
background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
if (background != -1)
setBackgroundColor(background);
}
}