本文整理汇总了Java中android.content.res.TypedArray.getString方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getString方法的具体用法?Java TypedArray.getString怎么用?Java TypedArray.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initAttrs
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttrs(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MineFragmentCell);
String mTitle = ta.getString(R.styleable.MineFragmentCell_cell_title);
String mSubTitle = ta.getString(R.styleable.MineFragmentCell_cell_subtitle);
int mNotificationNum = ta.getInteger(R.styleable.MineFragmentCell_cell_notification_num, 0);
ta.recycle();
if (!TextUtils.isEmpty(mTitle)){
mTitleTv.setVisibility(VISIBLE);
mTitleTv.setText(mTitle);
}
if (!TextUtils.isEmpty(mSubTitle)){
mSubTitleTv.setVisibility(VISIBLE);
mSubTitleTv.setText(mSubTitle);
}
// if (mNotificationNum > 0) {
mNotificationTv.setVisibility(VISIBLE);
mNotificationTv.setText(mNotificationNum + "");
// }
}
示例2: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
inflate(context, R.layout.view_my_spinner, this);
this.mTextView = (TextView) findViewById(R.id.text);
setBackgroundResource(R.drawable.backgroud_rectangle_border);
ImageView icon = (ImageView) findViewById(R.id.icon);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MySpinnerView);
try {
this.mHintText = a.getString(R.styleable.MySpinnerView_spinner_hint);
this.mHintColor = a.getColor(R.styleable.MySpinnerView_spinner_hint_color, Color.GRAY);
this.mTextColor = a.getColor(R.styleable.MySpinnerView_spinner_text_color, Color.BLACK);
int iconColor = a.getColor(R.styleable.MySpinnerView_spinner_icon_color, Color.BLUE);
icon.setColorFilter(iconColor, PorterDuff.Mode.MULTIPLY);
} finally {
a.recycle();
}
mTextView.setText(mHintText);
mTextView.setTextColor(mHintColor);
}
示例3: RRecyclerView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public RRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RRecyclerView);
isEnableAutoStartScroll = typedArray.getBoolean(R.styleable.RRecyclerView_r_enable_auto_start_scroll, isEnableAutoStartScroll);
enableScroll = typedArray.getBoolean(R.styleable.RRecyclerView_r_enable_scroll, enableScroll);
autoScrollToLastPosition = typedArray.getBoolean(R.styleable.RRecyclerView_r_auto_scroll_to_last_position, autoScrollToLastPosition);
autoScrollTimeInterval = typedArray.getInt(R.styleable.RRecyclerView_r_auto_scroll_time_interval, (int) autoScrollTimeInterval);
widthHeightRatio = typedArray.getString(R.styleable.RRecyclerView_r_width_height_ratio);
equWidth = typedArray.getBoolean(R.styleable.RRecyclerView_r_is_aeq_width, equWidth);
supportsChangeAnimations = typedArray.getBoolean(R.styleable.RRecyclerView_r_supports_change_animations, supportsChangeAnimations);
typedArray.recycle();
initView(context);
}
示例4: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* 初始化自定义属性值
* @param context 上下文
* @param attrs 属性资源
*/
private void init(Context context,AttributeSet attrs){
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TitleBar);
//左边按钮属性赋值
mLeftButtonText = typedArray.getString(R.styleable.TitleBar_leftButtonText);
mLeftButtonTextColor = typedArray.getColor(R.styleable.TitleBar_leftButtonTextColor, Color.WHITE);
mLeftButtonTextSize = typedArray.getDimension(R.styleable.TitleBar_leftButtonTextSize,
DensityUtil.sp2px(18));
mLeftButtonBackground = typedArray.getDrawable(R.styleable.TitleBar_leftButtonBackground);
//中间文字赋值
mTitleText = typedArray.getString(R.styleable.TitleBar_titleText);
mTitleTextColor = typedArray.getColor(R.styleable.TitleBar_titleColor, Color.WHITE);
mTitleTextSize = typedArray.getDimension(R.styleable.TitleBar_titleSize,
DensityUtil.sp2px(18));
//右边按钮属性赋值
mRightButtonText = typedArray.getString(R.styleable.TitleBar_rightButtonText);
mRightButtonTextColor = typedArray.getColor(R.styleable.TitleBar_rightButtonTextColor, Color.WHITE);
mRightButtonTextSize = typedArray.getDimension(R.styleable.TitleBar_rightButtonTextSize,
DensityUtil.sp2px(18));
mRightButtonBackground = typedArray.getDrawable(R.styleable.TitleBar_rightButtonBackground);
//回收typeArray以免发生内存泄漏
typedArray.recycle();
}
示例5: initAttr
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttr(@Nullable AttributeSet attrs)
{
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CountDownProgress);
if (a != null)
{
// circleRadius = a.getDimensionPixelOffset(R.styleable.CountDownProgress_cdp_circle_radius, dp2px(17));
circleSolidColor = a.getColor(R.styleable.CountDownProgress_cdp_circle_solid_color, 0xccaaaaaa);
circleStrokeWidth =
a.getDimensionPixelOffset(R.styleable.CountDownProgress_cdp_circle_stroke_width, dp2px(2));
circleColor = a.getColor(R.styleable.CountDownProgress_cdp_circle_stroke_color, 0xffe0e0e0);
progressColor = a.getColor(R.styleable.CountDownProgress_cdp_progress_color, 0xff5e5e5e);
progressWidth =
a.getDimensionPixelOffset(R.styleable.CountDownProgress_cdp_progress_width, circleStrokeWidth);
textColor = a.getColor(R.styleable.CountDownProgress_cdp_text_color, 0xffffffff);
textSize = a.getDimensionPixelSize(R.styleable.CountDownProgress_cdp_text_size, dp2px(14));
text = a.getString(R.styleable.CountDownProgress_cdp_text);
countDownTime = a.getInt(R.styleable.CountDownProgress_cdp_count_down_time, 5000);
startDegree = a.getFloat(R.styleable.CountDownProgress_cdp_start_degree, 270f);
if (TextUtils.isEmpty(text))
text = "跳过";
a.recycle();
}
}
示例6: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Initializes the required ripple views
* @param context
* @param attrs
*/
private void init(Context context, AttributeSet attrs) {
if (isInEditMode()) {
return;
}
//reading the attributes
TypedArray attrValues = context.obtainStyledAttributes(attrs, R.styleable.RipplePulseLayout);
int color = attrValues.getColor(R.styleable.RipplePulseLayout_rippleColor, getResources().getColor(android.R.color.holo_blue_bright));
float startRadius = attrValues.getDimension(R.styleable.RipplePulseLayout_startRadius, getMeasuredWidth());
float endRadius = attrValues.getDimension(R.styleable.RipplePulseLayout_endRadius, getMeasuredWidth() * 2);
float strokeWidth = attrValues.getDimension(R.styleable.RipplePulseLayout_strokeWidth, 4);
int duration = attrValues.getInteger(R.styleable.RipplePulseLayout_duration, DEFAULT_DURATION);
String rippleType = attrValues.getString(R.styleable.RipplePulseLayout_rippleType);
if (TextUtils.isEmpty(rippleType)) {
rippleType = RIPPLE_TYPE_FILL;
}
//initialize stuff
initializePaint(color, rippleType, strokeWidth);
initializeRippleView(endRadius, startRadius, strokeWidth);
initializeAnimators(startRadius, endRadius, duration);
}
示例7: handleStyledAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
@Override
protected void handleStyledAttributes(TypedArray a) {
// Set Show Indicator to the XML value, or default value
mShowIndicator = a.getBoolean(R.styleable.PullToRefresh_ptrShowIndicator, !isPullToRefreshOverScrollEnabled());
// Get IndicatorLayout code
String layoutCode = null;
if (a.hasValue(R.styleable.PullToRefresh_ptrIndicatorStyle)) {
layoutCode = a.getString(R.styleable.PullToRefresh_ptrIndicatorStyle);
}
// Convert layoutCode to a class token, and assign the class token into mIndicatorLayoutClazz
mIndicatorLayoutClazz = IndicatorLayoutFactory.createIndicatorLayoutClazzByLayoutCode(layoutCode);
}
示例8: TagsTextView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public TagsTextView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TagsTextView);
String string = typedArray.getString(R.styleable.TagsTextView_r_tags);
mTagMargin = typedArray.getDimensionPixelOffset(R.styleable.TagsTextView_r_tag_margin,
getResources().getDimensionPixelOffset(R.dimen.base_mdpi));
mTagSpaceV = typedArray.getDimensionPixelOffset(R.styleable.TagsTextView_r_tag_space_v,
0);
mTagSpaceH = typedArray.getDimensionPixelOffset(R.styleable.TagsTextView_r_tag_space_h,
0);
typedArray.recycle();
setTags(string);
}
示例9: initComponent
import android.content.res.TypedArray; //导入方法依赖的package包/类
@Override
public void initComponent(AttributeSet attrs) {
TypedArray attrArr = getContext().obtainStyledAttributes(attrs, R.styleable.ga_wrapper);
gaClickEvent = new GaEvent(attrArr.getString(R.styleable.ga_wrapper_category),
attrArr.getString(R.styleable.ga_wrapper_action),
attrArr.getString(R.styleable.ga_wrapper_label),
attrArr.getString(R.styleable.ga_wrapper_custom_dimension1),
attrArr.getString(R.styleable.ga_wrapper_custom_dimension2));
gaItemClickEvent = new GaEvent(attrArr.getString(R.styleable.ga_wrapper_category),
attrArr.getString(R.styleable.ga_wrapper_action),
attrArr.getString(R.styleable.ga_wrapper_label),
attrArr.getString(R.styleable.ga_wrapper_custom_dimension1),
attrArr.getString(R.styleable.ga_wrapper_custom_dimension2));
attrArr.recycle();
}
示例10: readFontFamilyTypeface
import android.content.res.TypedArray; //导入方法依赖的package包/类
private Typeface readFontFamilyTypeface(int resId) {
final TypedArray a = mView.getContext().obtainStyledAttributes(resId,
new int[]{android.R.attr.fontFamily});
try {
final String family = a.getString(0);
if (family != null) {
return Typeface.create(family, Typeface.NORMAL);
}
} finally {
a.recycle();
}
return null;
}
示例11: RemindItem
import android.content.res.TypedArray; //导入方法依赖的package包/类
public RemindItem(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.lingju);
title=a.getString(R.styleable.lingju_item_title);
frequency=a.getInt(R.styleable.lingju_frequency, 0);
time=a.getInt(R.styleable.lingju_time, 0);
a.recycle();
init(context);
}
示例12: initComponent
import android.content.res.TypedArray; //导入方法依赖的package包/类
@Override
public void initComponent(AttributeSet attrs) {
TypedArray attrArr = getContext().obtainStyledAttributes(attrs, R.styleable.ga_wrapper);
gaEvent = new GaEvent(attrArr.getString(R.styleable.ga_wrapper_category),
attrArr.getString(R.styleable.ga_wrapper_action),
attrArr.getString(R.styleable.ga_wrapper_label),
attrArr.getString(R.styleable.ga_wrapper_custom_dimension1),
attrArr.getString(R.styleable.ga_wrapper_custom_dimension2));
attrArr.recycle();
}
示例13: CardSliderLayoutManager
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Constructor used when layout manager is set in XML by RecyclerView attribute
* "layoutManager".
*
* See {@link R.styleable#CardSlider_activeCardLeftOffset}
* See {@link R.styleable#CardSlider_cardWidth}
* See {@link R.styleable#CardSlider_cardsGap}
*/
public CardSliderLayoutManager(@NonNull Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
final float density = context.getResources().getDisplayMetrics().density;
final int defaultCardWidth = (int) (DEFAULT_CARD_WIDTH * density);
final int defaultActiveCardLeft = (int) (DEFAULT_ACTIVE_CARD_LEFT_OFFSET * density);
final float defaultCardsGap = DEFAULT_CARDS_GAP * density;
if (attrs == null) {
initialize(defaultActiveCardLeft, defaultCardWidth, defaultCardsGap, null);
} else {
int attrCardWidth;
int attrActiveCardLeft;
float attrCardsGap;
String viewUpdateClassName;
final TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CardSlider, 0, 0);
try {
attrCardWidth = a.getDimensionPixelSize(R.styleable.CardSlider_cardWidth, defaultCardWidth);
attrActiveCardLeft = a.getDimensionPixelSize(R.styleable.CardSlider_activeCardLeftOffset, defaultActiveCardLeft);
attrCardsGap = a.getDimension(R.styleable.CardSlider_cardsGap, defaultCardsGap);
viewUpdateClassName = a.getString(R.styleable.CardSlider_viewUpdater);
} finally {
a.recycle();
}
final ViewUpdater viewUpdater = loadViewUpdater(context, viewUpdateClassName, attrs);
initialize(attrActiveCardLeft, attrCardWidth, attrCardsGap, viewUpdater);
}
}
示例14: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(@Nullable AttributeSet attrs) {
TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.LottieAnimationView);
String fileName = ta.getString(R.styleable.LottieAnimationView_lottie_fileName);
if (!isInEditMode() && fileName != null) {
setAnimation(fileName);
}
if (ta.getBoolean(R.styleable.LottieAnimationView_lottie_autoPlay, false)) {
lottieDrawable.playAnimation();
}
lottieDrawable.loop(ta.getBoolean(R.styleable.LottieAnimationView_lottie_loop, false));
setImageAssetsFolder(ta.getString(R.styleable.LottieAnimationView_lottie_imageAssetsFolder));
setProgress(ta.getFloat(R.styleable.LottieAnimationView_lottie_progress, 0));
int cacheStrategy = ta.getInt(
R.styleable.LottieAnimationView_lottie_cacheStrategy,
CacheStrategy.None.ordinal());
defaultCacheStrategy = CacheStrategy.values()[cacheStrategy];
ta.recycle();
setLayerType(LAYER_TYPE_SOFTWARE, null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
float systemAnimationScale = Settings.Global.getFloat(getContext().getContentResolver(),
Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f);
if (systemAnimationScale == 0f) {
lottieDrawable.systemAnimationsAreDisabled();
}
}
}
示例15: MemoItem
import android.content.res.TypedArray; //导入方法依赖的package包/类
public MemoItem(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.lingju);
content=a.getString(R.styleable.lingju_item_title);
a.recycle();
init(context);
}