本文整理汇总了Java中android.content.res.TypedArray.getText方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getText方法的具体用法?Java TypedArray.getText怎么用?Java TypedArray.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
final Resources.Theme theme = context.getTheme();
int[] styles = new int[]{-2000244};
TypedArray a = theme.obtainStyledAttributes(
attrs, styles, defStyleAttr, 0);
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
switch (attr) {
case -2002018:
mText = a.getText(attr);
break;
}
}
a.recycle();
if (!TextUtils.isEmpty(mText)) {
setColorText((String) mText);
}
}
示例2: TextClock
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Creates a new clock inflated from XML. This object's properties are
* intialized from the attributes specified in XML.
*
* @param context The Context the view is running in, through which it can
* access the current theme, resources, etc.
* @param attrs The attributes of the XML tag that is inflating the view
* @param defStyle The default style to apply to this view. If 0, no style
* will be applied (beyond what is included in the theme). This may
* either be an attribute resource, whose value will be retrieved
* from the current theme, or an explicit style resource
*/
public TextClock(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextClock, defStyle, 0);
try {
CharSequence format;
format = a.getText(R.styleable.TextClock_format12Hour);
mFormat12 = format == null ? DEFAULT_FORMAT_12_HOUR : format;
format = a.getText(R.styleable.TextClock_format24Hour);
mFormat24 = format == null ? DEFAULT_FORMAT_24_HOUR : format;
mTimeZone = a.getString(R.styleable.TextClock_timeZone);
} finally {
a.recycle();
}
init();
}
示例3: initView
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Init view.
*
* @param attrs
*/
private void initView(AttributeSet attrs)
{
TypedArray typedArray = mContext.obtainStyledAttributes(attrs, R.styleable.x_preference);
CharSequence prefsKey = typedArray.getText(R.styleable.x_preference_prefs_key);
CharSequence prefsDefault = typedArray.getText(R.styleable.x_preference_prefs_default);
if (!TextUtils.isEmpty(prefsKey))
{
mPrefsKey = prefsKey.toString();
}
if (!TextUtils.isEmpty(prefsDefault))
{
mPrefsDefault = prefsDefault.toString();
}
typedArray.recycle();
}
示例4: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyleAttr) {
final TypedArray a = getContext().obtainStyledAttributes(attrs,
R.styleable.SuwGlifLayout, defStyleAttr, 0);
final Drawable icon = a.getDrawable(R.styleable.SuwGlifLayout_android_icon);
if (icon != null) {
setIcon(icon);
}
// Set the header color
final ColorStateList headerColor =
a.getColorStateList(R.styleable.SuwGlifLayout_suwHeaderColor);
if (headerColor != null) {
setHeaderColor(headerColor);
}
// Set the header text
final CharSequence headerText =
a.getText(R.styleable.SuwGlifLayout_suwHeaderText);
if (headerText != null) {
setHeaderText(headerText);
}
final ColorStateList primaryColor =
a.getColorStateList(R.styleable.SuwGlifLayout_android_colorPrimary);
setPrimaryColor(primaryColor);
a.recycle();
}
示例5: FloatLabelLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public FloatLabelLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setOrientation(VERTICAL);
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);
int leftPadding =
a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft,
dipsToPix(DEFAULT_LABEL_PADDING_LEFT));
int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop,
dipsToPix(DEFAULT_LABEL_PADDING_TOP));
int rightPadding =
a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight,
dipsToPix(DEFAULT_LABEL_PADDING_RIGHT));
int bottomPadding =
a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom,
dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM));
mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint);
mLabel = new TextView(context);
mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
mLabel.setVisibility(INVISIBLE);
mLabel.setText(mHint);
ViewCompat.setPivotX(mLabel, 0f);
ViewCompat.setPivotY(mLabel, 0f);
mLabel.setTextAppearance(context,
a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance,
android.R.style.TextAppearance_Small));
a.recycle();
addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
mInterpolator = AnimationUtils.loadInterpolator(context,
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
? android.R.interpolator.fast_out_slow_in
: android.R.anim.decelerate_interpolator);
}
示例6: TabItem
import android.content.res.TypedArray; //导入方法依赖的package包/类
public TabItem(Context context, AttributeSet attrs) {
super(context, attrs);
final TypedArray a =
context.getResources().obtainAttributes(attrs, R.styleable.TabItem);
mText = a.getText(R.styleable.TabItem_android_text);
mIcon = a.getDrawable(R.styleable.TabItem_android_icon);
mCustomLayout = a.getResourceId(R.styleable.TabItem_android_layout, 0);
a.recycle();
}
示例7: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
public void init(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
final Resources.Theme theme = context.getTheme();
TypedArray a = theme.obtainStyledAttributes(attrs,
com.android.internal.R.styleable.TextView, defStyleAttr, defStyleRes);
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
switch (attr) {
case com.android.internal.R.styleable.TextView_gravity:
mGravity = a.getInt(attr, Gravity.TOP | Gravity.LEFT);
break;
case com.android.internal.R.styleable.TextView_text:
mText = a.getText(attr);
break;
case com.android.internal.R.styleable.TextView_ellipsize:
mEllipsize = a.getInt(attr, mEllipsize);
break;
case com.android.internal.R.styleable.TextView_maxLines:
mMaxLines = a.getInt(attr, Integer.MAX_VALUE);
break;
case com.android.internal.R.styleable.TextView_textColor:
// Do not support ColorState
mTextColor = a.getColor(attr, Color.BLACK);
break;
case com.android.internal.R.styleable.TextView_textSize:
mTextSize = a.getDimensionPixelSize(attr, 15);
break;
case com.android.internal.R.styleable.TextView_lineSpacingExtra:
mSpacingAdd = a.getDimensionPixelSize(attr, mSpacingAdd);
break;
case com.android.internal.R.styleable.TextView_lineSpacingMultiplier:
mSpacingMultiplier = a.getFloat(attr, mSpacingMultiplier);
break;
}
}
}
示例8: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.EmptyView);
try {
//Loading state attrs
loadingText = a.getText(R.styleable.EmptyView_loadingText);
loadingTextColor = a.getColor(R.styleable.EmptyView_loadingTextColor, Color.BLACK);
loadingBackgroundColor = a.getColor(R.styleable.EmptyView_loadingBackgroundColor, 0);
loadingDrawable = a.getDrawable(R.styleable.EmptyView_loadingDrawable);
loadingTint = a.getColor(R.styleable.EmptyView_loadingTint, 0);
loadingStyle = a.getInt(R.styleable.EmptyView_loadingStyle, Style.CIRCULAR);
//Empty state attrs
emptyText = a.getText(R.styleable.EmptyView_emptyText);
emptyTextColor = a.getColor(R.styleable.EmptyView_emptyTextColor, Color.BLACK);
emptyBackgroundColor = a.getColor(R.styleable.EmptyView_emptyBackgroundColor, 0);
emptyDrawable = a.getDrawable(R.styleable.EmptyView_emptyDrawable);
emptyTint = a.getColor(R.styleable.EmptyView_emptyDrawableTint, 0);
emptyGravity = a.getInt(R.styleable.EmptyView_emptyGravity, Position.CENTER);
//Error state attrs
errorText = a.getText(R.styleable.EmptyView_errorText);
errorTextColor = a.getColor(R.styleable.EmptyView_errorTextColor, Color.BLACK);
errorButtonText = a.getText(R.styleable.EmptyView_errorButtonText);
errorButtonTextColor = a.getColor(R.styleable.EmptyView_errorButtonTextColor, Color.BLACK);
errorButtonBackgroundColor = a.getColor(R.styleable.EmptyView_errorButtonBackgroundColor, 0);
errorBackgroundColor = a.getColor(R.styleable.EmptyView_errorBackgroundColor, 0);
errorDrawable = a.getDrawable(R.styleable.EmptyView_errorDrawable);
errorTint = a.getColor(R.styleable.EmptyView_errorDrawableTint, 0);
} finally {
a.recycle();
}
}
示例9: readItem
import android.content.res.TypedArray; //导入方法依赖的package包/类
public void readItem(AttributeSet attrs) {
TypedArray a = SupportMenuInflater.this.mContext.obtainStyledAttributes(attrs, R.styleable.MenuItem);
this.itemId = a.getResourceId(R.styleable.MenuItem_android_id, 0);
this.itemCategoryOrder = (SupportMenu.CATEGORY_MASK & a.getInt(R.styleable.MenuItem_android_menuCategory, this.groupCategory)) | (65535 & a.getInt(R.styleable.MenuItem_android_orderInCategory, this.groupOrder));
this.itemTitle = a.getText(R.styleable.MenuItem_android_title);
this.itemTitleCondensed = a.getText(R.styleable.MenuItem_android_titleCondensed);
this.itemIconResId = a.getResourceId(R.styleable.MenuItem_android_icon, 0);
this.itemAlphabeticShortcut = getShortcut(a.getString(R.styleable.MenuItem_android_alphabeticShortcut));
this.itemNumericShortcut = getShortcut(a.getString(R.styleable.MenuItem_android_numericShortcut));
if (a.hasValue(R.styleable.MenuItem_android_checkable)) {
int i;
if (a.getBoolean(R.styleable.MenuItem_android_checkable, false)) {
i = 1;
} else {
i = 0;
}
this.itemCheckable = i;
} else {
this.itemCheckable = this.groupCheckable;
}
this.itemChecked = a.getBoolean(R.styleable.MenuItem_android_checked, false);
this.itemVisible = a.getBoolean(R.styleable.MenuItem_android_visible, this.groupVisible);
this.itemEnabled = a.getBoolean(R.styleable.MenuItem_android_enabled, this.groupEnabled);
this.itemShowAsAction = a.getInt(R.styleable.MenuItem_showAsAction, -1);
this.itemListenerMethodName = a.getString(R.styleable.MenuItem_android_onClick);
this.itemActionViewLayout = a.getResourceId(R.styleable.MenuItem_actionLayout, 0);
this.itemActionViewClassName = a.getString(R.styleable.MenuItem_actionViewClass);
this.itemActionProviderClassName = a.getString(R.styleable.MenuItem_actionProviderClass);
boolean hasActionProvider = this.itemActionProviderClassName != null;
if (hasActionProvider && this.itemActionViewLayout == 0 && this.itemActionViewClassName == null) {
this.itemActionProvider = (ActionProvider) newInstance(this.itemActionProviderClassName, SupportMenuInflater.ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE, SupportMenuInflater.this.mActionProviderConstructorArguments);
} else {
if (hasActionProvider) {
Log.w(SupportMenuInflater.LOG_TAG, "Ignoring attribute 'actionProviderClass'. Action view already specified.");
}
this.itemActionProvider = null;
}
a.recycle();
this.itemAdded = false;
}
示例10: prepare
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void prepare(AttributeSet attrs)
{
setBaselineAligned(false);
setVerticalGravity(Gravity.CENTER_VERTICAL);
setOrientation(HORIZONTAL);
final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.horizontal_number_picker, this);
editText = ((EditText) findViewById(R.id.edit_text_value));
if (attrs != null)
{
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.HorizontalNumberPicker, 0, 0);
CharSequence label = a.getText(R.styleable.HorizontalNumberPicker_label);
if (label != null)
{
((TextView) findViewById(R.id.label_text)).setText(label);
}
editText.setMinimumWidth(a.getDimensionPixelSize(R.styleable.HorizontalNumberPicker_minWidth, 0));
a.recycle();
}
bDecrease = (ImageButton) findViewById(R.id.button_decrease);
bDecrease.setOnClickListener(this);
bDecrease.setOnLongClickListener(this);
updateViewColor(bDecrease);
bIncrease = (ImageButton) findViewById(R.id.button_increase);
bIncrease.setOnClickListener(this);
bIncrease.setOnLongClickListener(this);
updateViewColor(bIncrease);
description = (TextView) findViewById(R.id.label_text);
}
示例11: ToggleButton
import android.content.res.TypedArray; //导入方法依赖的package包/类
@SuppressLint("RestrictedApi")
public ToggleButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(TintContextWrapper.wrap(context), attrs, defStyleAttr);
mCompoundButtonHelper = new AppCompatCompoundButtonHelper(this);
mCompoundButtonHelper.loadFromAttributes(attrs, defStyleAttr);
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.ToggleButton, defStyleAttr, R.style.Widget_Material_ToggleButton);
mTextOn = a.getText(R.styleable.ToggleButton_textOn);
mTextOff = a.getText(R.styleable.ToggleButton_textOff);
syncTextState();
a.recycle();
}
示例12: ButtonItem
import android.content.res.TypedArray; //导入方法依赖的package包/类
public ButtonItem(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuwButtonItem);
mEnabled = a.getBoolean(R.styleable.SuwButtonItem_android_enabled, true);
mText = a.getText(R.styleable.SuwButtonItem_android_text);
mTheme = a.getResourceId(R.styleable.SuwButtonItem_android_theme, R.style.SuwButtonItem);
a.recycle();
}
示例13: HelperTextInputLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public HelperTextInputLayout(Context _context, AttributeSet _attrs) {
super(_context, _attrs);
final TypedArray a = getContext().obtainStyledAttributes(
_attrs,
R.styleable.HelperTextInputLayout,0,0);
try {
mHelperTextColor = a.getColorStateList(R.styleable.HelperTextInputLayout_helperTextColor);
mHelperText = a.getText(R.styleable.HelperTextInputLayout_helperText);
} finally {
a.recycle();
}
}
示例14: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Called from one of constructors of this view to perform its initialization.
* <p>
* Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
* this view specific data from it that can be used to configure this new view instance. The
* specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
* from the current theme provided by the specified <var>context</var>.
*/
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
/**
* Process attributes.
*/
this.mEditConfig = new EditConfig();
boolean createViewHierarchy = true;
final TypedArray attributes = mContext.obtainStyledAttributes(attrs, R.styleable.Ui_EditLayout, defStyleAttr, defStyleRes);
for (int i = 0; i < attributes.getIndexCount(); i++) {
final int index = attributes.getIndex(i);
if (index == R.styleable.Ui_EditLayout_android_text) {
mEditConfig.text = attributes.getText(index);
} else if (index == R.styleable.Ui_EditLayout_android_hint) {
mEditConfig.hint = attributes.getText(index);
} else if (index == R.styleable.Ui_EditLayout_android_inputType) {
mEditConfig.inputType = attributes.getInteger(index, mEditConfig.inputType);
} else if (index == R.styleable.Ui_EditLayout_android_maxLength) {
mLengthConstraint = mEditConfig.maxLength = attributes.getInteger(index, mEditConfig.maxLength);
} else if (index == R.styleable.Ui_EditLayout_android_lines) {
mEditConfig.lines = attributes.getInteger(index, mEditConfig.lines);
} else if (index == R.styleable.Ui_EditLayout_android_minLines) {
mEditConfig.minLines = attributes.getInteger(index, mEditConfig.minLines);
} else if (index == R.styleable.Ui_EditLayout_android_maxLines) {
mEditConfig.maxLines = attributes.getInteger(index, mEditConfig.maxLines);
} else if (index == R.styleable.Ui_EditLayout_uiLengthConstraint) {
this.mLengthConstraint = attributes.getInteger(index, mLengthConstraint);
} else if (index == R.styleable.Ui_EditLayout_uiFloatingLabelAnimationIn) {
final int inAnimRes = attributes.getResourceId(index, -1);
if (inAnimRes != -1) {
this.mLabelInAnimation = AnimationUtils.loadAnimation(mContext, inAnimRes);
}
} else if (index == R.styleable.Ui_EditLayout_uiFloatingLabelAnimationOut) {
final int outAnimRes = attributes.getResourceId(index, -1);
if (outAnimRes != -1) {
this.mLabelOutAnimation = AnimationUtils.loadAnimation(mContext, outAnimRes);
this.handleAnimationsUpdate();
}
} else if (index == R.styleable.Ui_EditLayout_uiWithEmptyViewHierarchy) {
createViewHierarchy = !attributes.getBoolean(index, false);
}
}
attributes.recycle();
if (createViewHierarchy) {
addLabelView(new TextViewWidget(context, null, R.attr.uiInputLabelStyle));
addInputView(new EditTextWidget(context, null, R.attr.uiEditTextInputStyle));
addNoteView(new TextViewWidget(context, null, R.attr.uiInputNoteStyle));
addConstraintView(new TextViewWidget(context, null, R.attr.uiInputConstraintStyle));
this.updateEditTextConfiguration();
}
}
示例15: ButtonIcon
import android.content.res.TypedArray; //导入方法依赖的package包/类
public ButtonIcon(Context context, AttributeSet attrs)
{
super(context, attrs);
initInflater(context);
initView(context);
final TypedArray typed = context.obtainStyledAttributes(attrs, R.styleable.ButtonIcon);
final DisplayMetrics dm = getResources().getDisplayMetrics();
mTextSize = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mTextSize, dm);
final int res = typed.getResourceId(R.styleable.ButtonIcon_android_src, R.drawable.ic_github_logo);
final CharSequence charS = typed.getText(R.styleable.ButtonIcon_android_text);
final int color = typed.getColor(R.styleable.ButtonIcon_android_textColor, Color.parseColor("#212121"));
final int mTextSize = typed.getDimensionPixelSize(R.styleable.ButtonIcon_android_textSize, 14);
final String stringTypeface = typed.getString(R.styleable.ButtonIcon_android_typeface);
final Boolean typefaceB = typed.getBoolean(R.styleable.ButtonIcon_isTypeface, mState);
final int colorB = typed.getColor(R.styleable.ButtonIcon_android_background, Color.parseColor("#CCCCCC"));
final Drawable f = typed.getDrawable(R.styleable.ButtonIcon_android_foreground);
setImageResource(res);
setText(charS);
setTextColor(color);
setTextSize(mTextSize);
if (typefaceB)
{
mState = typefaceB;
mState = true;
isTypeface(true, Typeface.createFromAsset(context.getAssets(), "fonts/" + stringTypeface + ".ttf"));
}
else
{
mState = typefaceB;
mState = false;
}
setColorBackground(colorB);
setForeground(f);
typed.recycle();
setOutlineProvider(ViewOutlineProvider.BOUNDS);
}