android.content.res.TypedArray#getTextArray()源码实例Demo

下面列出了android.content.res.TypedArray#getTextArray() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PreferenceFragment   文件: ListPreference.java
public ListPreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.ListPreference, 0, 0);
    mEntries = a.getTextArray(R.styleable.ListPreference_entries);
    mEntryValues = a.getTextArray(R.styleable.ListPreference_entryValues);
    a.recycle();

    /* Retrieve the Preference summary attribute since it's private
     * in the Preference class.
     */
    a = context.obtainStyledAttributes(attrs,
            R.styleable.Preference, 0, 0);
    mSummary = a.getString(R.styleable.Preference_summary);
    a.recycle();
}
 
源代码2 项目: material-drawer   文件: LinearListView.java
public LinearListView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs,
            R_styleable_LinearListView);

    // Use the thickness specified, zero being the default
    final int thickness = a.getDimensionPixelSize(
            LinearListView_dividerThickness, 0);
    if (thickness != 0) {
        setDividerThickness(thickness);
    }

    CharSequence[] entries = a.getTextArray(LinearListView_entries);
    if (entries != null) {
        setAdapter(new ArrayAdapter<>(context,
                android.R.layout.simple_list_item_1, entries));
    }

    a.recycle();
}
 
源代码3 项目: android_9.0.0_r45   文件: MultiCheckPreference.java
public MultiCheckPreference(
        Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    TypedArray a = context.obtainStyledAttributes(
            attrs, com.android.internal.R.styleable.ListPreference, defStyleAttr, defStyleRes);
    mEntries = a.getTextArray(com.android.internal.R.styleable.ListPreference_entries);
    if (mEntries != null) {
        setEntries(mEntries);
    }
    setEntryValuesCS(a.getTextArray(
            com.android.internal.R.styleable.ListPreference_entryValues));
    a.recycle();

    /* Retrieve the Preference summary attribute since it's private
     * in the Preference class.
     */
    a = context.obtainStyledAttributes(attrs,
            com.android.internal.R.styleable.Preference, 0, 0);
    mSummary = a.getString(com.android.internal.R.styleable.Preference_summary);
    a.recycle();
}
 
源代码4 项目: android_9.0.0_r45   文件: AbsSpinner.java
public AbsSpinner(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    // Spinner is important by default, unless app developer overrode attribute.
    if (getImportantForAutofill() == IMPORTANT_FOR_AUTOFILL_AUTO) {
        setImportantForAutofill(IMPORTANT_FOR_AUTOFILL_YES);
    }

    initAbsSpinner();

    final TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.AbsSpinner, defStyleAttr, defStyleRes);

    final CharSequence[] entries = a.getTextArray(R.styleable.AbsSpinner_entries);
    if (entries != null) {
        final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(
                context, R.layout.simple_spinner_item, entries);
        adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
        setAdapter(adapter);
    }

    a.recycle();
}
 
@Override
    protected void init(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) {
        super.init(context, attrs, defStyleAttr, defStyleRes);
        TypedArray a = context.obtainStyledAttributes(
                attrs, R.styleable.ListPreference, defStyleAttr, defStyleRes);
        mEntries = a.getTextArray(R.styleable.ListPreference_entries);
        mEntryValues = a.getTextArray(R.styleable.ListPreference_entryValues);
        a.recycle();

        /* Retrieve the Preference summary attribute since it's private
         * in the Preference class.
         */
//    a=context.obtainStyledAttributes(attrs,
//            R.styleable.Preference,defStyleAttr,defStyleRes);
//    mSummary=a.getString(R.styleable.Preference_summary);
//    a.recycle();
        mSummary = super.getSummary() == null ? null : super.getSummary().toString();
    }
 
源代码6 项目: MyBookshelf   文件: IconListPreference.java
public IconListPreference(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.IconListPreference, 0, 0);

    CharSequence[] drawables;

    try {
        drawables = a.getTextArray(R.styleable.IconListPreference_icons);
    } finally {
        a.recycle();
    }

    for (CharSequence drawable : drawables) {
        int resId = context.getResources().getIdentifier(drawable.toString(), "mipmap", context.getPackageName());

        Drawable d = context.getResources().getDrawable(resId);

        mEntryDrawables.add(d);
    }

    setWidgetLayoutResource(R.layout.view_icon);
}
 
源代码7 项目: ticdesign   文件: ListPreference.java
public ListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.ListPreference, defStyleAttr, defStyleRes);
    mEntries = a.getTextArray(R.styleable.ListPreference_android_entries);
    mEntryValues = a.getTextArray(R.styleable.ListPreference_android_entryValues);
    a.recycle();

    /* Retrieve the Preference summary attribute since it's private
     * in the Preference class.
     */
    a = context.obtainStyledAttributes(attrs,
            R.styleable.Preference, defStyleAttr, defStyleRes);
    mSummary = a.getString(R.styleable.Preference_android_summary);
    a.recycle();
}
 
源代码8 项目: fastnfitness   文件: SingleValueInputView.java
protected void init(Context context, AttributeSet attrs) {

        rootView = inflate(context, R.layout.singlevalueinput_view, this);
        titleTextView = rootView.findViewById(R.id.singlevalueinput_title);
        valueEditText = rootView.findViewById(R.id.singlevalueinput_value);
        unitSpinner = rootView.findViewById(R.id.singlevalueinput_unitSpinner);
        commentTextView = rootView.findViewById(R.id.singlevalueinput_comment);
        commentLayout = rootView.findViewById(R.id.singlevalueinput_commentLayout);

        TypedArray a = context.getTheme().obtainStyledAttributes(
            attrs,
            R.styleable.SingleValueInputView,
            0, 0);

        try {
            mShowUnit = a.getBoolean(R.styleable.SingleValueInputView_showUnit, false);
            setShowUnit(mShowUnit);
            mShowComment = a.getBoolean(R.styleable.SingleValueInputView_showComment, false);
            setShowComment(mShowComment);
            mTitle = a.getString(R.styleable.SingleValueInputView_title);
            setTitle(mTitle);
            mComment = a.getString(R.styleable.SingleValueInputView_comment);
            setComment(mComment);
            mValue = a.getString(R.styleable.SingleValueInputView_value);
            setValue(mValue);
            mType = a.getInteger(R.styleable.SingleValueInputView_type, 0);
            setType(mType);
            CharSequence[] entries = a.getTextArray(R.styleable.SingleValueInputView_units);
            if (entries != null)
            {
                setUnits(entries);
            }
        } finally {
            a.recycle();
        }
    }
 
public MultiSelectListPreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.MultiSelectListPreference, 0, 0);
    mEntries = a.getTextArray(R.styleable.MultiSelectListPreference_entries);
    mEntryValues = a.getTextArray(R.styleable.MultiSelectListPreference_entryValues);
    a.recycle();
}
 
源代码10 项目: android-cassowary-layout   文件: CassowaryLayout.java
private void readConstraintsFromXml(AttributeSet attrs) {
    TypedArray a = getContext().getTheme().obtainStyledAttributes(
            attrs,
            R.styleable.CassowaryLayout,
            0, 0);

    try {
        final CharSequence[] constraints = a.getTextArray(R.styleable.CassowaryLayout_constraints);

        asyncSetup = a.getBoolean(R.styleable.CassowaryLayout_asyncSetup, asyncSetup);
        aspectRatioFixed = a.getBoolean(R.styleable.CassowaryLayout_aspectRatioFixed, aspectRatioFixed);
        aspectRatioWidthFactor = a.getFloat(R.styleable.CassowaryLayout_aspectRatioWidthFactor, aspectRatioWidthFactor);
        aspectRatioHeightFactor = a.getFloat(R.styleable.CassowaryLayout_aspectRatioHeightFactor, aspectRatioHeightFactor);

        log("readConstraintsFromXml asyncSetup " + asyncSetup );
        if (asyncSetup) {
            setupSolverAsync(constraints);
        } else {
            cassowaryModel.addConstraints(constraints);
            state = State.PARSING_COMPLETE;
        }

        if (constraints == null) {
            throw new RuntimeException("missing cassowary:constraints attribute in XML");
        }

    } finally {
        a.recycle();
    }

}
 
源代码11 项目: MHViewer   文件: ListPreference.java
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    setNegativeButtonText(android.R.string.cancel);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPreference, defStyleAttr, defStyleRes);
    mEntries = a.getTextArray(R.styleable.ListPreference_entries);
    mEntryValues = a.getTextArray(R.styleable.ListPreference_entryValues);
    a.recycle();

    /* Retrieve the Preference summary attribute since it's private
     * in the Preference class.
     */
    a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.summary}, defStyleAttr, defStyleRes);
    mSummary = a.getString(0);
    a.recycle();
}
 
public MultiSelectDragListPreference(Context context, AttributeSet attrs)
{
	super(context, attrs);

	TypedArray a = context.obtainStyledAttributes(attrs,
			R.styleable.MultiSelectDragListPreference, 0, 0);
	mEntries = a.getTextArray(R.styleable.MultiSelectDragListPreference_entries);
	mEntryValues = a.getTextArray(R.styleable.MultiSelectDragListPreference_entryValues);
	a.recycle();
}
 
源代码13 项目: Klyph   文件: HListView.java
public HListView( Context context, AttributeSet attrs, int defStyle ) {
	super( context, attrs, defStyle );

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

	CharSequence[] entries = a.getTextArray( R.styleable.HListView_android_entries );
	if ( entries != null ) {
		setAdapter( new ArrayAdapter<CharSequence>( context, android.R.layout.simple_list_item_1, entries ) );
	}

	final Drawable d = a.getDrawable( R.styleable.HListView_android_divider );
	if ( d != null ) {
		// If a divider is specified use its intrinsic height for divider height
		setDivider( d );
	}

	final Drawable osHeader = a.getDrawable( R.styleable.HListView_overScrollHeader );
	if ( osHeader != null ) {
		setOverscrollHeader( osHeader );
	}

	final Drawable osFooter = a.getDrawable( R.styleable.HListView_overScrollFooter );
	if ( osFooter != null ) {
		setOverscrollFooter( osFooter );
	}

	// Use the height specified, zero being the default
	final int dividerWidth = a.getDimensionPixelSize( R.styleable.HListView_dividerWidth, 0 );
	if ( dividerWidth != 0 ) {
		setDividerWidth( dividerWidth );
	}

	mHeaderDividersEnabled = a.getBoolean( R.styleable.HListView_headerDividersEnabled, true );
	mFooterDividersEnabled = a.getBoolean( R.styleable.HListView_footerDividersEnabled, true );
	mMeasureWithChild = a.getInteger( R.styleable.HListView_measureWithChild, -1 );
	
	Log.d( LOG_TAG, "mMeasureWithChild: " + mMeasureWithChild );

	a.recycle();
}
 
源代码14 项目: MDPreference   文件: ListPreference.java
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.list_preference, defStyleAttr, defStyleRes);
    mEntries = a.getTextArray(R.styleable.list_preference_entry_arr);
    mEntryValues = a.getTextArray(R.styleable.list_preference_value_arr);
    mFormat = a.getString(R.styleable.list_preference_format_str);
    a.recycle();
}
 
源代码15 项目: RangeSeekBar   文件: RangeSeekBar.java
private void initAttrs(AttributeSet attrs) {
    try {
        TypedArray t = getContext().obtainStyledAttributes(attrs, R.styleable.RangeSeekBar);
        seekBarMode = t.getInt(R.styleable.RangeSeekBar_rsb_mode, SEEKBAR_MODE_RANGE);
        minProgress = t.getFloat(R.styleable.RangeSeekBar_rsb_min, 0);
        maxProgress = t.getFloat(R.styleable.RangeSeekBar_rsb_max, 100);
        minInterval = t.getFloat(R.styleable.RangeSeekBar_rsb_min_interval, 0);
        gravity = t.getInt(R.styleable.RangeSeekBar_rsb_gravity, Gravity.TOP);
        progressColor = t.getColor(R.styleable.RangeSeekBar_rsb_progress_color, 0xFF4BD962);
        progressRadius = (int) t.getDimension(R.styleable.RangeSeekBar_rsb_progress_radius, -1);
        progressDefaultColor = t.getColor(R.styleable.RangeSeekBar_rsb_progress_default_color, 0xFFD7D7D7);
        progressDrawableId = t.getResourceId(R.styleable.RangeSeekBar_rsb_progress_drawable, 0);
        progressDefaultDrawableId = t.getResourceId(R.styleable.RangeSeekBar_rsb_progress_drawable_default, 0);
        progressHeight = (int) t.getDimension(R.styleable.RangeSeekBar_rsb_progress_height, Utils.dp2px(getContext(), 2));
        tickMarkMode = t.getInt(R.styleable.RangeSeekBar_rsb_tick_mark_mode, TRICK_MARK_MODE_NUMBER);
        tickMarkGravity = t.getInt(R.styleable.RangeSeekBar_rsb_tick_mark_gravity, TICK_MARK_GRAVITY_CENTER);
        tickMarkLayoutGravity = t.getInt(R.styleable.RangeSeekBar_rsb_tick_mark_layout_gravity, Gravity.TOP);
        tickMarkTextArray = t.getTextArray(R.styleable.RangeSeekBar_rsb_tick_mark_text_array);
        tickMarkTextMargin = (int) t.getDimension(R.styleable.RangeSeekBar_rsb_tick_mark_text_margin, Utils.dp2px(getContext(), 7));
        tickMarkTextSize = (int) t.getDimension(R.styleable.RangeSeekBar_rsb_tick_mark_text_size, Utils.dp2px(getContext(), 12));
        tickMarkTextColor = t.getColor(R.styleable.RangeSeekBar_rsb_tick_mark_text_color, progressDefaultColor);
        tickMarkInRangeTextColor = t.getColor(R.styleable.RangeSeekBar_rsb_tick_mark_text_color, progressColor);
        steps = t.getInt(R.styleable.RangeSeekBar_rsb_steps, 0);
        stepsColor = t.getColor(R.styleable.RangeSeekBar_rsb_step_color, 0xFF9d9d9d);
        stepsRadius = t.getDimension(R.styleable.RangeSeekBar_rsb_step_radius, 0);
        stepsWidth = t.getDimension(R.styleable.RangeSeekBar_rsb_step_width, 0);
        stepsHeight = t.getDimension(R.styleable.RangeSeekBar_rsb_step_height, 0);
        stepsDrawableId = t.getResourceId(R.styleable.RangeSeekBar_rsb_step_drawable, 0);
        stepsAutoBonding = t.getBoolean(R.styleable.RangeSeekBar_rsb_step_auto_bonding, true);
        t.recycle();
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
源代码16 项目: QuestionnaireView   文件: QuestionnaireView.java
private void parseAttributes(Context context, AttributeSet attrs, int defStyleAttr) {
    drawInnerViews(context, attrs);
    TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.QuestionBaseView);
    int viewType = values.getInt(R.styleable.QuestionBaseView_view_type, 1);
    setViewType(viewType);
    String text = values.getString(R.styleable.QuestionBaseView_question);
    setQuestion(text);
    CharSequence[] answers =  values.getTextArray(R.styleable.QuestionBaseView_entries);
    if(answers != null) setAnswers(answers);

    values.recycle();
}
 
@Override
protected Object onGetDefaultValue(TypedArray a, int index)
{
	final CharSequence[] defaultValues = a.getTextArray(index);
	final int valueCount = defaultValues.length;
	final List<String> result = new ArrayList<String>();

	for (int i = 0; i < valueCount; i++)
	{
		result.add(defaultValues[i].toString());
	}

	return result;
}
 
源代码18 项目: HaoReader   文件: TextInputSpinner.java
@SuppressLint("RestrictedApi")
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    setInputType(InputType.TYPE_NULL);
    setCursorVisible(false);
    Drawable arrow = getResources().getDrawable(R.drawable.ic_arrow_drop_down_black_24dp);
    arrow.setBounds(0, 0, arrow.getIntrinsicWidth(), arrow.getIntrinsicHeight());
    setCompoundDrawablesRelative(null, null, arrow, null);
    AppCompat.setTint(arrow, getResources().getColor(R.color.colorMenuText));

    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.TextInputSpinner, defStyleAttr, 0);
    mEntities = a.getTextArray(R.styleable.TextInputSpinner_android_entries);
    a.recycle();

    mPopup = new ListPopupWindow(context, attrs, defStyleAttr, R.style.AppTheme_PopupMenu_Overflow);
    mPopup.setAdapter(new ArrayAdapter<>(context, R.layout.support_simple_spinner_dropdown_item, mEntities));
    mPopup.setOnItemClickListener((parent, view, position, id) -> {
        setSelection(position);
        mPopup.dismiss();
    });
    mPopup.setAnchorView(this);
    mPopup.setVerticalOffset(-ScreenUtils.dpToPx(5));
    mPopup.setHorizontalOffset(ScreenUtils.dpToPx(4));
    mPopup.setWidth(getResources().getDisplayMetrics().widthPixels - ScreenUtils.dpToPx(16));
    mPopup.setModal(true);

    setSelection(0);
}
 
源代码19 项目: CircleRangeView   文件: CircleRangeView.java
public CircleRangeView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircleRangeView);

    rangeColorArray = typedArray.getTextArray(R.styleable.CircleRangeView_rangeColorArray);
    rangeValueArray = typedArray.getTextArray(R.styleable.CircleRangeView_rangeValueArray);
    rangeTextArray = typedArray.getTextArray(R.styleable.CircleRangeView_rangeTextArray);

    borderColor = typedArray.getColor(R.styleable.CircleRangeView_borderColor, borderColor);
    cursorColor = typedArray.getColor(R.styleable.CircleRangeView_cursorColor, cursorColor);
    extraTextColor = typedArray.getColor(R.styleable.CircleRangeView_extraTextColor, extraTextColor);

    rangeTextSize = typedArray.getDimensionPixelSize(R.styleable.CircleRangeView_rangeTextSize, rangeTextSize);
    extraTextSize = typedArray.getDimensionPixelSize(R.styleable.CircleRangeView_extraTextSize, extraTextSize);

    typedArray.recycle();

    if (rangeColorArray == null || rangeValueArray == null || rangeTextArray == null) {
        throw new IllegalArgumentException("CircleRangeView : rangeColorArray、 rangeValueArray、rangeTextArray  must be not null ");
    }
    if (rangeColorArray.length != rangeValueArray.length
            || rangeColorArray.length != rangeTextArray.length
            || rangeValueArray.length != rangeTextArray.length) {
        throw new IllegalArgumentException("arrays must be equal length");
    }

    this.mSection = rangeColorArray.length;

    mSparkleWidth = dp2px(15);
    mCalibrationWidth = dp2px(10);

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStrokeCap(Paint.Cap.ROUND);

    mRectFProgressArc = new RectF();
    mRectFCalibrationFArc = new RectF();
    mRectText = new Rect();

    mBackgroundColor = android.R.color.transparent;
}
 
源代码20 项目: MDPreference   文件: MultiSelectListPreference.java
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.list_preference, defStyleAttr, defStyleRes);
    mEntries = a.getTextArray(R.styleable.list_preference_entry_arr);
    a.recycle();
}