List of usage examples for android.content.res TypedArray getString
@Nullable public String getString(@StyleableRes int index)
From source file:br.liveo.searchliveo.SearchLiveo.java
private void initAttribute(Context context, AttributeSet attributeSet, int defStyleAttr) { TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.search_liveo, defStyleAttr, 0); if (attr != null) { try {//from ww w . j a va2 s .com if (attr.hasValue(R.styleable.search_liveo_search_liveo_hint)) { hint(attr.getString(R.styleable.search_liveo_search_liveo_hint)); } if (attr.hasValue(R.styleable.search_liveo_search_liveo_text_color)) { mEdtSearch.setTextColor(attr.getColor(R.styleable.search_liveo_search_liveo_text_color, -1)); } if (attr.hasValue(R.styleable.search_liveo_search_liveo_hint_color)) { mEdtSearch .setHintTextColor(attr.getColor(R.styleable.search_liveo_search_liveo_hint_color, -1)); } if (attr.hasValue(R.styleable.search_liveo_search_liveo_color_icon)) { setColorIcon(attr.getColor(R.styleable.search_liveo_search_liveo_color_icon, -1)); } if (attr.hasValue(R.styleable.search_liveo_search_liveo_color_arrow)) { setColorIconArrow(attr.getColor(R.styleable.search_liveo_search_liveo_color_arrow, -1)); } if (attr.hasValue(R.styleable.search_liveo_search_liveo_color_voice)) { setColorIconVoice(attr.getColor(R.styleable.search_liveo_search_liveo_color_voice, -1)); } if (attr.hasValue(R.styleable.search_liveo_search_liveo_color_close)) { setColorIconClose(attr.getColor(R.styleable.search_liveo_search_liveo_color_close, -1)); } if (attr.hasValue(R.styleable.search_liveo_search_liveo_background)) { mViewSearch.setBackgroundColor( attr.getColor(R.styleable.search_liveo_search_liveo_background, -1)); } if (attr.hasValue(R.styleable.search_liveo_search_liveo_status_bar_show_color)) { setStatusBarShowColor( attr.getColor(R.styleable.search_liveo_search_liveo_status_bar_show_color, -1)); } if (attr.hasValue(R.styleable.search_liveo_search_liveo_status_bar_hide_color)) { setStatusBarHideColor( attr.getColor(R.styleable.search_liveo_search_liveo_status_bar_hide_color, -1)); } } finally { attr.recycle(); } } }
From source file:br.liveo.searchliveo.SearchCardLiveo.java
private void initAttribute(Context context, AttributeSet attributeSet, int defStyleAttr) { TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.search_card_liveo, defStyleAttr, 0);/* ww w. j av a 2 s. com*/ if (attr != null) { try { if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_hint)) { hint(attr.getString(R.styleable.search_card_liveo_search_card_liveo_hint)); } if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_text_color)) { mEdtSearch.setTextColor( attr.getColor(R.styleable.search_card_liveo_search_card_liveo_text_color, -1)); } if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_hint_color)) { mEdtSearch.setHintTextColor( attr.getColor(R.styleable.search_card_liveo_search_card_liveo_hint_color, -1)); } if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_color_icon)) { setColorIcon(attr.getColor(R.styleable.search_card_liveo_search_card_liveo_color_icon, -1)); } if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_color_arrow)) { setColorIconArrow( attr.getColor(R.styleable.search_card_liveo_search_card_liveo_color_arrow, -1)); } if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_color_voice)) { setColorIconVoice( attr.getColor(R.styleable.search_card_liveo_search_card_liveo_color_voice, -1)); } if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_color_close)) { setColorIconClose( attr.getColor(R.styleable.search_card_liveo_search_card_liveo_color_close, -1)); } if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_background)) { mCardSearch.setBackgroundColor( attr.getColor(R.styleable.search_card_liveo_search_card_liveo_background, -1)); } if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_status_bar_show_color)) { setStatusBarShowColor(attr .getColor(R.styleable.search_card_liveo_search_card_liveo_status_bar_show_color, -1)); } if (attr.hasValue(R.styleable.search_card_liveo_search_card_liveo_status_bar_hide_color)) { setStatusBarHideColor(attr .getColor(R.styleable.search_card_liveo_search_card_liveo_status_bar_hide_color, -1)); } } finally { attr.recycle(); } } }
From source file:com.chao.facebookzc.widget.LoginButton.java
private void parseAttributes(AttributeSet attrs) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.com_facebook_login_view); confirmLogout = a.getBoolean(R.styleable.com_facebook_login_view_confirm_logout, true); fetchUserInfo = a.getBoolean(R.styleable.com_facebook_login_view_fetch_user_info, true); loginText = a.getString(R.styleable.com_facebook_login_view_login_text); logoutText = a.getString(R.styleable.com_facebook_login_view_logout_text); a.recycle();/*from w ww .j a v a 2 s . c o m*/ }
From source file:com.gm.grecyclerview.GmRecyclerView.java
private void initAttrs(Context context, AttributeSet attrs, int defStyle) { TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.grv_GRecyclerView, defStyle, 0);/*w ww . j av a 2 s.c o m*/ layoutMode = typedArray.getInt(R.styleable.grv_GRecyclerView_grv_layoutMode, 0); gridSpanCount = typedArray.getInt(R.styleable.grv_GRecyclerView_grv_gridSpanCount, 0); gridSpanSequence = typedArray.getString(R.styleable.grv_GRecyclerView_grv_gridSpanSequence); spacing = typedArray.getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_spacing, 0); verticalSpacing = typedArray.getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_verticalSpacing, 0); horizontalSpacing = typedArray.getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_horizontalSpacing, 0); isSpacingIncludeEdge = typedArray.getBoolean(R.styleable.grv_GRecyclerView_grv_isSpacingIncludeEdge, false); showDivider = typedArray.getBoolean(R.styleable.grv_GRecyclerView_grv_showDivider, false); showLastDivider = typedArray.getBoolean(R.styleable.grv_GRecyclerView_grv_showLastDivider, false); dividerColor = typedArray.getColor(R.styleable.grv_GRecyclerView_grv_dividerColor, 0); dividerOrientation = typedArray.getInt(R.styleable.grv_GRecyclerView_grv_dividerOrientation, 2); dividerPaddingLeft = typedArray.getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_dividerPaddingLeft, 0); dividerPaddingRight = typedArray .getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_dividerPaddingRight, 0); dividerPaddingTop = typedArray.getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_dividerPaddingTop, 0); dividerPaddingBottom = typedArray .getDimensionPixelSize(R.styleable.grv_GRecyclerView_grv_dividerPaddingBottom, 0); isSnappyEnabled = typedArray.getBoolean(R.styleable.grv_GRecyclerView_grv_snappy, false); snapAlignment = typedArray.getInt(R.styleable.grv_GRecyclerView_grv_snap_alignment, 0); showEmptyStateView = typedArray.getBoolean(R.styleable.grv_GRecyclerView_grv_showEmptyStateView, false); emptyStateViewRes = typedArray.getResourceId(R.styleable.grv_GRecyclerView_grv_emptyStateView, 0); loadMoreViewRes = typedArray.getResourceId(R.styleable.grv_GRecyclerView_grv_loadMoreView, 0); typedArray.recycle(); }
From source file:nuclei.ui.view.GlideImageView.java
void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GlideImageView, defStyleAttr, defStyleRes);//w w w.j av a2s . c o m mDownloadState = sDefaultDownloadState; mCircle = a.getBoolean(R.styleable.GlideImageView_circle, false); mRatio = a.getFloat(R.styleable.GlideImageView_ratio, 0); mRadius = a.getDimensionPixelSize(R.styleable.GlideImageView_radius, 0); mPlaceholderId = a.getResourceId(R.styleable.GlideImageView_placeholder, 0); if (a.hasValue(R.styleable.GlideImageView_border_color)) { int borderColor = a.getColor(R.styleable.GlideImageView_border_color, 0); float borderWidth = a.getDimensionPixelSize(R.styleable.GlideImageView_border_width, 0); setBorder(borderColor, borderWidth); } String uri = a.getString(R.styleable.GlideImageView_url); boolean preload = a.getBoolean(R.styleable.GlideImageView_preload, true); a.recycle(); if (preload) { if (!isInEditMode()) { if (uri == null) { setPlaceHolder(); } else setImageURI(uri); } else setPlaceHolder(); } }
From source file:im.ene.ribbon.BottomNavigationView.java
private void initialize(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) { typeface = new SoftReference<>(Typeface.DEFAULT); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.BottomNavigationView, defStyleAttr, defStyleRes);//from ww w .j a v a 2s . c om final int menuResId = array.getResourceId(R.styleable.BottomNavigationView_ribbon_menu, 0); if (menuResId == 0) { throw new IllegalArgumentException("A valid menu must be set in xml"); } pendingMenu = MenuParser.inflateMenu(context, menuResId); badgeProvider = parseBadgeProvider(this, context, array.getString(R.styleable.BottomNavigationView_ribbon_badgeProvider)); array.recycle(); backgroundColorAnimation = getResources().getInteger(R.integer.ribbon_background_animation_duration); defaultSelectedIndex = 0; defaultHeight = getResources().getDimensionPixelSize(R.dimen.ribbon_bottom_navigation_height); defaultWidth = getResources().getDimensionPixelSize(R.dimen.ribbon_bottom_navigation_width); shadowHeight = getResources().getDimensionPixelOffset(R.dimen.ribbon_top_shadow_height); // check if the bottom navigation is translucent if (!isInEditMode()) { final Activity activity = MiscUtils.getActivity(context); if (activity != null) { final SystemBarTintManager systemBarTintManager = new SystemBarTintManager(activity); if (MiscUtils.hasTranslucentNavigationBar(activity) && // systemBarTintManager.getConfig().isNavigationAtBottom() && // systemBarTintManager.getConfig().hasNavigtionBar()) { bottomInset = systemBarTintManager.getConfig().getNavigationBarHeight(); } else { bottomInset = 0; } topInset = systemBarTintManager.getConfig().getStatusBarHeight(); } } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT); params.topMargin = shadowHeight; backgroundOverlay = new View(getContext()); backgroundOverlay.setLayoutParams(params); addView(backgroundOverlay); }
From source file:zxyilian.com.myapplication.ui.ProgressWheel.java
/** * Parse the attributes passed to the view from the XML * * @param a the attributes to parse/* ww w. j a va2s . c o m*/ */ private void parseAttributes(TypedArray a) { barWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwBarWidth, barWidth); rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwRimWidth, rimWidth); spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_pwSpinSpeed, spinSpeed); barLength = (int) a.getDimension(R.styleable.ProgressWheel_pwBarLength, barLength); delayMillis = a.getInteger(R.styleable.ProgressWheel_pwDelayMillis, delayMillis); if (delayMillis < 0) { delayMillis = 10; } // Only set the text if it is explicitly defined if (a.hasValue(R.styleable.ProgressWheel_pwText)) { setText(a.getString(R.styleable.ProgressWheel_pwText)); } barColor = a.getColor(R.styleable.ProgressWheel_pwBarColor, barColor); textColor = a.getColor(R.styleable.ProgressWheel_pwTextColor, textColor); rimColor = a.getColor(R.styleable.ProgressWheel_pwRimColor, rimColor); circleColor = a.getColor(R.styleable.ProgressWheel_pwCircleColor, circleColor); contourColor = a.getColor(R.styleable.ProgressWheel_pwContourColor, contourColor); textSize = (int) a.getDimension(R.styleable.ProgressWheel_pwTextSize, textSize); contourSize = a.getDimension(R.styleable.ProgressWheel_pwContourSize, contourSize); a.recycle(); }
From source file:com.nihaskalam.progressbuttonlibrary.CircularProgressButton.java
private void initAttributes(Context context, AttributeSet attributeSet) { String xmlProvidedSize = attributeSet.getAttributeValue("http://schemas.android.com/apk/res/android", "textSize"); String[] parts = xmlProvidedSize.split("\\."); String part1 = parts[0];/*from w w w.j a v a 2 s. com*/ textSize = new Integer(part1); if (textSize < 0) { float sourceTextSize = getTextSize(); textSize = (int) (sourceTextSize / getContext().getResources().getDisplayMetrics().density); } TypedArray attr = getTypedArray(context, attributeSet, R.styleable.CircularProgressButton); if (attr == null) { return; } try { mIdleText = attr.getString(R.styleable.CircularProgressButton_pb_textIdle); mCompleteText = attr.getString(R.styleable.CircularProgressButton_pb_textComplete); mCancelText = attr.getString(R.styleable.CircularProgressButton_pb_textCancel); mErrorText = attr.getString(R.styleable.CircularProgressButton_pb_textError); mProgressText = attr.getString(R.styleable.CircularProgressButton_pb_textProgress); mIconComplete = attr.getResourceId(R.styleable.CircularProgressButton_pb_iconComplete, 0); mIconCancel = attr.getResourceId(R.styleable.CircularProgressButton_pb_iconCancel, 0); mIconError = attr.getResourceId(R.styleable.CircularProgressButton_pb_iconError, 0); mCornerRadius = attr.getDimension(R.styleable.CircularProgressButton_pb_cornerRadius, 0); mPaddingProgress = attr.getDimensionPixelSize(R.styleable.CircularProgressButton_pb_paddingProgress, 0); mIndeterminateProgressMode = attr.getBoolean(R.styleable.CircularProgressButton_pb_isIndeterminate, false); int blue = getColor(R.color.pb_blue); int white = getColor(R.color.pb_white); int grey = getColor(R.color.pb_grey); int idleStateSelector = attr.getResourceId(R.styleable.CircularProgressButton_pb_selectorIdle, R.color.pb_idle_state_selector); mIdleColorState = ContextCompat.getColorStateList(context, idleStateSelector); int completeStateSelector = attr.getResourceId(R.styleable.CircularProgressButton_pb_selectorComplete, R.color.pb_complete_state_selector); mCompleteColorState = ContextCompat.getColorStateList(context, completeStateSelector); int cancelStateSelector = attr.getResourceId(R.styleable.CircularProgressButton_pb_selectorCancel, R.color.pb_cancel_state_selector); mCancelColorState = ContextCompat.getColorStateList(context, cancelStateSelector); int errorStateSelector = attr.getResourceId(R.styleable.CircularProgressButton_pb_selectorError, R.color.pb_error_state_selector); mErrorColorState = ContextCompat.getColorStateList(context, errorStateSelector); mColorProgress = attr.getColor(R.styleable.CircularProgressButton_pb_colorProgress, white); mColorIndicator = attr.getColor(R.styleable.CircularProgressButton_pb_colorIndicator, blue); mColorProgressCancelIcon = attr.getColor(R.styleable.CircularProgressButton_pb_colorProgressCancelIcon, mColorIndicator); mColorIndicatorBackground = attr .getColor(R.styleable.CircularProgressButton_pb_colorIndicatorBackground, grey); mIdleStateTextColorAfterClick = attr.getColor(R.styleable.CircularProgressButton_pb_textColorAfterClick, getNormalColor(mIdleColorState)); if (idleStateStrokeColor != -1) { mIdleStateBackgroundColorAfterClick = attr.getColor( R.styleable.CircularProgressButton_pb_backgroundColorAfterClick, getColor(idleStateStrokeColor)); } else { mIdleStateBackgroundColorAfterClick = attr.getColor( R.styleable.CircularProgressButton_pb_backgroundColorAfterClick, getPressedColor(mIdleColorState)); } mColorCancelText = attr.getColor(R.styleable.CircularProgressButton_pb_colorCancelText, getNormalColor(this.getTextColors())); mColorCompleteText = attr.getColor(R.styleable.CircularProgressButton_pb_colorCompleteText, getNormalColor(this.getTextColors())); mColorErrorText = attr.getColor(R.styleable.CircularProgressButton_pb_colorErrorText, getNormalColor(this.getTextColors())); mColorIdleText = getNormalColor(this.getTextColors()); } finally { attr.recycle(); } }
From source file:com.hippo.vectorold.drawable.AnimatedVectorDrawable.java
public void inflate(Context context, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException { Resources res = context.getResources(); int eventType = parser.getEventType(); float pathErrorScale = 1; while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { final String tagName = parser.getName(); if (ANIMATED_VECTOR.equals(tagName)) { final TypedArray a = res.obtainAttributes(attrs, R.styleable.AnimatedVectorDrawable); int drawableRes = a.getResourceId(R.styleable.AnimatedVectorDrawable_drawable, 0); if (drawableRes != 0) { VectorDrawable vectorDrawable = (VectorDrawable) res.getDrawable(drawableRes).mutate(); vectorDrawable.setAllowCaching(false); pathErrorScale = vectorDrawable.getPixelSize(); mAnimatedVectorState.mVectorDrawable = vectorDrawable; }// w w w. j a v a 2 s . c om a.recycle(); } else if (TARGET.equals(tagName)) { final TypedArray a = res.obtainAttributes(attrs, R.styleable.AnimatedVectorDrawableTarget); final String target = a.getString(R.styleable.AnimatedVectorDrawableTarget_name); int id = a.getResourceId(R.styleable.AnimatedVectorDrawableTarget_animation, 0); if (id != 0) { Animator objectAnimator = AnimatorInflater.loadAnimator(context, id, pathErrorScale); setupAnimatorsForTarget(target, objectAnimator); } a.recycle(); } } eventType = parser.next(); } }
From source file:com.eutectoid.dosomething.picker.PickerFragment.java
@Override public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(activity, attrs, savedInstanceState); TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.picker_fragment); setShowPictures(a.getBoolean(R.styleable.picker_fragment_show_pictures, showPictures)); String extraFieldsString = a.getString(R.styleable.picker_fragment_extra_fields); if (extraFieldsString != null) { String[] strings = extraFieldsString.split(","); setExtraFields(Arrays.asList(strings)); }/*from w w w .j a v a 2 s . c o m*/ showTitleBar = a.getBoolean(R.styleable.picker_fragment_show_title_bar, showTitleBar); titleText = a.getString(R.styleable.picker_fragment_title_text); doneButtonText = a.getString(R.styleable.picker_fragment_done_button_text); titleBarBackground = a.getDrawable(R.styleable.picker_fragment_title_bar_background); doneButtonBackground = a.getDrawable(R.styleable.picker_fragment_done_button_background); a.recycle(); }