本文整理匯總了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);
}
}