Example usage for android.content.res TypedArray getString

List of usage examples for android.content.res TypedArray getString

Introduction

In this page you can find the example usage for android.content.res TypedArray getString.

Prototype

@Nullable
public String getString(@StyleableRes int index) 

Source Link

Document

Retrieves the string value for the attribute at index.

Usage

From source file:com.ewintory.footballscores.ui.widget.AnimatorStateView.java

private void initialize(Context context, AttributeSet attrs, int defStyle) {
    mRoot = LayoutInflater.from(context).inflate(R.layout.widget_animator_state, this, true);
    ButterKnife.bind(this, mRoot);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatorStateView, defStyle, 0);

    String text = a.getString(R.styleable.AnimatorStateView_messageText);
    Drawable image = a.getDrawable(R.styleable.AnimatorStateView_messageImage);

    mTextView.setText(text);/*  www .  jav  a  2  s .c  o  m*/
    mImageView.setImageDrawable(image);

    a.recycle();

    mScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}

From source file:loc.lbs.view.DateRecyclerView.java

private void setDates(TypedArray typedArray) {
    String dateStart = typedArray.getString(R.styleable.DateRecyclerViewWidget_date_start);
    String dateEnd = typedArray.getString(R.styleable.DateRecyclerViewWidget_date_end);

    String defaultDaySelection = typedArray.getString(R.styleable.DateRecyclerViewWidget_default_day_selection);
    Date defaultDate = null;//from  w w w.  j a va 2s . c o  m

    if (dateStart == null || dateEnd == null) {
        return;
    }

    try {
        if (defaultDaySelection != null && !defaultDaySelection.isEmpty()) {
            defaultDate = PagerDatePickerDateFormat.DATE_PICKER_DD_MM_YYYY_FORMAT.parse(defaultDaySelection);
        }
    } catch (ParseException e) {
        Log.w(TAG, "Problem to parse default date selection", e);
    }

    try {
        Date start = PagerDatePickerDateFormat.DATE_PICKER_DD_MM_YYYY_FORMAT.parse(dateStart);
        Date end = PagerDatePickerDateFormat.DATE_PICKER_DD_MM_YYYY_FORMAT.parse(dateEnd);
        defaultDateAdapter = new DefaultDateAdapter(start, end, defaultDate);
    } catch (ParseException e) {
        Log.e(TAG, "The start/end date is incorrect", e);
    }
}

From source file:com.ez.gallery.ucrop.view.widget.AspectRatioTextView.java

@SuppressWarnings("deprecation")
private void init(@NonNull TypedArray a) {
    setGravity(Gravity.CENTER_HORIZONTAL);

    mAspectRatioTitle = a.getString(R.styleable.ucrop_AspectRatioTextView_ucrop_artv_ratio_title);
    mAspectRatioX = a.getFloat(R.styleable.ucrop_AspectRatioTextView_ucrop_artv_ratio_x,
            CropImageView.SOURCE_IMAGE_ASPECT_RATIO);
    mAspectRatioY = a.getFloat(R.styleable.ucrop_AspectRatioTextView_ucrop_artv_ratio_y,
            CropImageView.SOURCE_IMAGE_ASPECT_RATIO);

    if (mAspectRatioX == CropImageView.SOURCE_IMAGE_ASPECT_RATIO
            || mAspectRatioY == CropImageView.SOURCE_IMAGE_ASPECT_RATIO) {
        mAspectRatio = CropImageView.SOURCE_IMAGE_ASPECT_RATIO;
    } else {// w w w . j a v a 2  s  . c  om
        mAspectRatio = mAspectRatioX / mAspectRatioY;
    }

    mDotSize = getContext().getResources().getDimensionPixelSize(R.dimen.ucrop_size_dot_scale_text_view);
    mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDotPaint.setStyle(Paint.Style.FILL);

    setTitle();

    int activeColor = getResources().getColor(R.color.ucrop_color_widget_active);
    applyActiveColor(activeColor);
}

From source file:com.dattasmoon.pebble.plugin.ConvertPreference.java

@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
    return (a.getString(index));
}

From source file:com.wolkabout.hexiwear.view.Input.java

public Input(final Context context, final AttributeSet attrs) {
    super(context, attrs);
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Input);
    defaultText = typedArray.getString(R.styleable.Input_text);
    hint = typedArray.getString(R.styleable.Input_hint);
    drawable = typedArray.getResourceId(R.styleable.Input_drawable, 0);
    maxLength = typedArray.getResourceId(R.styleable.Input_maxLength, 100);
    actionLabel = typedArray.getString(R.styleable.Input_actionLabel);
    textColor = typedArray.getColor(R.styleable.Input_textColor,
            ContextCompat.getColor(getContext(), R.color.primary_text));

    final int typeOrdinal = typedArray.getInt(R.styleable.Input_type, InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    type = Type.byOrdinal(typeOrdinal);

    typedArray.recycle();//from w ww . j  a va2  s.  co  m
}

From source file:org.strongswan.android.ui.view.TextInputLayoutHelper.java

public TextInputLayoutHelper(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextInputLayoutHelper);
    String helper = a.getString(R.styleable.TextInputLayoutHelper_helper_text);
    a.recycle();/*from  w w  w .ja  va2s.c  o m*/
    if (helper != null) {
        mHelperContainer = new LinearLayout(context);
        mHelperContainer.setOrientation(LinearLayout.HORIZONTAL);
        mHelperContainer.setVisibility(View.INVISIBLE);
        addView(mHelperContainer, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

        mHelperText = new TextView(context);
        mHelperText.setText(helper);
        mHelperText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
        a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.textColorSecondary });
        mHelperText.setTextColor(a.getColor(0, mHelperText.getCurrentTextColor()));
        a.recycle();

        mHelperContainer.addView(mHelperText, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    }
}

From source file:com.tasomaniac.android.widget.IntegrationPreference.java

private void extractIntegrationIntent(TypedArray sa) {
    integrationIntent = new Intent();

    integrationIntent.setAction(sa.getString(R.styleable.IntegrationPreference_integrationIntentAction));

    String data = sa.getString(R.styleable.IntegrationPreference_integrationIntentData);
    String mimeType = sa.getString(R.styleable.IntegrationPreference_integrationIntentMimeType);
    if (data != null) {
        integrationIntent.setData(Uri.parse(data));
    }/*  w w w . j a  va  2  s  .  co m*/
    if (mimeType != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            integrationIntent.setTypeAndNormalize(mimeType);
        } else {
            integrationIntent.setType(mimeType);
        }
    }

    String packageName = sa.getString(R.styleable.IntegrationPreference_integrationIntentTargetPackage);
    String className = sa.getString(R.styleable.IntegrationPreference_integrationIntentTargetClass);
    if (packageName != null && className != null) {
        integrationIntent.setComponent(new ComponentName(packageName, className));
    }
}

From source file:paulscode.android.mupen64plusae.persistent.ProfilePreference.java

public ProfilePreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProfilePreference);
    mAllowDisable = a.getBoolean(R.styleable.ProfilePreference_allowDisable, DEFAULT_ALLOW_DISABLE);
    mManagerAction = a.getString(R.styleable.ProfilePreference_managerAction);
    a.recycle();//from  ww  w.  ja  va 2s . c  o m
}

From source file:net.alexjf.tmm.fragments.IconPickerFragment.java

private void updateIcons() {
    Resources res = getActivity().getResources();

    TypedArray iconCats = res.obtainTypedArray(R.array.iconcats);
    int numCategories = iconCats.length();

    iconCategories = new ArrayList<IconCategory>(numCategories);

    for (int i = 0; i < numCategories; i++) {
        int resId = iconCats.peekValue(i).resourceId;

        if (resId > 0) {
            IconCategory iconCat = new IconCategory();
            TypedArray catInfo = res.obtainTypedArray(resId);
            iconCat.title = catInfo.getString(0);
            int entriesResId = catInfo.getResourceId(1, 0);

            if (entriesResId > 0) {
                TypedArray icons = res.obtainTypedArray(entriesResId);
                int numIcons = icons.length();

                iconCat.drawableIds = new ArrayList<Integer>(numIcons);
                for (int j = 0; j < numIcons; j++) {
                    int drawableId = icons.getResourceId(j, 0);
                    iconCat.drawableIds.add(drawableId);
                }/*from w ww .  j  a  v a 2  s  .c  o m*/

                icons.recycle();
            } else {
                Log.e("TMM", "Error reading icon entries of cat with index " + i);
            }

            iconCategories.add(iconCat);
        } else {
            Log.e("TMM", "Error reading icon category with index " + i);
        }
    }

    iconCats.recycle();
    Collections.sort(iconCategories, new IconCategory.Comparator());
}

From source file:paulscode.android.mupen64plusae.preference.MultiSelectListPreference.java

/**
 * Instantiates a new multi-select list preference.
 * /* w w  w .jav a2  s . c  o  m*/
 * @param context The current context.
 * @param attrs   The attributes provided from the xml resource.
 */
public MultiSelectListPreference(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiSelectListPreference);
    String delimiter = a.getString(R.styleable.MultiSelectListPreference_delimiter);
    String separator = a.getString(R.styleable.MultiSelectListPreference_separator);
    a.recycle();

    mDelimiter = TextUtils.isEmpty(delimiter) ? DEFAULT_DELIMITER : delimiter;
    mSeparator = TextUtils.isEmpty(separator) ? DEFAULT_SEPARATOR : separator;

    setOnPreferenceChangeListener(null);
}