當前位置: 首頁>>代碼示例>>Java>>正文


Java TypedArray.getTextArray方法代碼示例

本文整理匯總了Java中android.content.res.TypedArray.getTextArray方法的典型用法代碼示例。如果您正苦於以下問題:Java TypedArray.getTextArray方法的具體用法?Java TypedArray.getTextArray怎麽用?Java TypedArray.getTextArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.TypedArray的用法示例。


在下文中一共展示了TypedArray.getTextArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ColorPickerPreference

import android.content.res.TypedArray; //導入方法依賴的package包/類
public ColorPickerPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ColorPickerPreference, defStyleAttr, 0);

    int colorsId = a.getResourceId(R.styleable.ColorPickerPreference_colors, R.array.color_picker_default_colors);

    if (colorsId != 0) {
        colors = context.getResources().getIntArray(colorsId);
    }

    colorDescriptions = a.getTextArray(R.styleable.ColorPickerPreference_colorDescriptions);
    color = a.getColor(R.styleable.ColorPickerPreference_currentColor, 0);
    columns = a.getInt(R.styleable.ColorPickerPreference_columns, 0);
    size = a.getInt(R.styleable.ColorPickerPreference_sizeImage, ColorPickerDialog.SIZE_SMALL);
    sortColors = a.getBoolean(R.styleable.ColorPickerPreference_sortColors, false);

    a.recycle();

    setWidgetLayoutResource(R.layout.preference_widget_color_swatch);
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:22,代碼來源:ColorPickerPreference.java

示例2: NoticeView

import android.content.res.TypedArray; //導入方法依賴的package包/類
public NoticeView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mContext = context;

    TypedArray ta = mContext.getTheme().obtainStyledAttributes(attrs, R.styleable.NoticeView, defStyleAttr, 0);
    mTextSize = ta.getDimensionPixelSize(R.styleable.NoticeView_textSize, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, DEF_TEXT_SIZE, getResources().getDisplayMetrics()));
    mTextColor = ta.getColor(R.styleable.NoticeView_textColor, DEF_TEXT_COLOR);
    verScrollDuration = ta.getInteger(R.styleable.NoticeView_verScrollDuration, DEF_VER_SCROLL_DURATION);
    horScrollDelay = ta.getInteger(R.styleable.NoticeView_horScrollDelay, DEF_HOR_SCROLL_DELAY);
    verScrollDelay = ta.getInteger(R.styleable.NoticeView_verScrollDelay, DEF_VER_SCROLL_DELAY);
    CharSequence[] notices = ta.getTextArray(R.styleable.NoticeView_notices);
    if (null != notices) {
        mNotices = Arrays.asList(notices);
    }

    ta.recycle();

    initial();
}
 
開發者ID:xu0xyc,項目名稱:android-noticeview,代碼行數:20,代碼來源:NoticeView.java

示例3: init

import android.content.res.TypedArray; //導入方法依賴的package包/類
/**
 * 初始化,包括必要的 {@link #paint} 等變量初始化,xml屬性獲取等.
 *
 * @param attrs {@link AttributeSet}
 */
private void init(AttributeSet attrs)
{
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Paint.Align.CENTER);

    toast = new Toast(context);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(Toast.LENGTH_SHORT);

    toastView = new RelativeLayout(context);
    toastView.setGravity(Gravity.CENTER);
    toast.setView(toastView);

    toastTextView = new TextView(context);
    toastTextView.setGravity(Gravity.CENTER);
    toastView.addView(toastTextView);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.QuickIndexView);
    textColor = typedArray.getColor(R.styleable.QuickIndexView_textColor, Colors.BLACK);
    quickTextColor = typedArray.getColor(R.styleable.QuickIndexView_quickTextColor, Colors.BLACK);
    topDrawable = typedArray.getDrawable(R.styleable.QuickIndexView_topDrawable);
    bottomDrawable = typedArray.getDrawable(R.styleable.QuickIndexView_bottomDrawable);

    showToast = typedArray.getBoolean(R.styleable.QuickIndexView_showToast, true);
    quickBackground = typedArray.getDrawable(R.styleable.QuickIndexView_quickBackground);
    quickWidth = typedArray.getDimensionPixelSize(R.styleable.QuickIndexView_quickWidth,
            DensityTool.dp2px(context, DEFAULT_WIDTH_DP));
    quickHeight = typedArray.getDimensionPixelSize(R.styleable.QuickIndexView_quickHeight,
            DensityTool.dp2px(context, DEFAULT_WIDTH_DP));

    changeToastViewSize();

    CharSequence[] textArray = typedArray.getTextArray(R.styleable.QuickIndexView_quickLetters);
    if(textArray != null)
    {
        letterList = new ArrayList<>();
        for(CharSequence charSequence : textArray)
        {
            letterList.add(charSequence.toString());
        }
    }
    else
    {
        setLetterArray(ResCompat.getStringArray(context, R.array.defaultQuickIndexViewLetters));
    }

    typedArray.recycle();

    bitmapRect = new Rect();
    outRect = new Rect();
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:58,代碼來源:QuickIndexView.java

示例4: initAttr

import android.content.res.TypedArray; //導入方法依賴的package包/類
private void initAttr(Context context, AttributeSet attrs){
    if (attrs == null) {
        return;
    }
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LoopView);
    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);
        if(attr == R.styleable.LoopView_npv_ShowCount){
            mShowCount = a.getInt(attr, DEFAULT_SHOW_COUNT);
        }else if(attr == R.styleable.LoopView_npv_DividerColor){
            mDividerColor = a.getColor(attr, DEFAULT_DIVIDER_COLOR);
        }else if(attr == R.styleable.LoopView_npv_DividerHeight){
            mDividerHeight = a.getDimensionPixelSize(attr, DEFAULT_DIVIDER_HEIGHT);
        }else if(attr == R.styleable.LoopView_npv_DividerMarginLeft){
            mDividerMarginL = a.getDimensionPixelSize(attr, DEFAULT_DIVIDER_MARGIN_HORIZONTAL);
        }else if(attr == R.styleable.LoopView_npv_DividerMarginRight){
            mDividerMarginR = a.getDimensionPixelSize(attr, DEFAULT_DIVIDER_MARGIN_HORIZONTAL);
        }else if(attr == R.styleable.LoopView_npv_TextArray){
            mDisplayedValues = convertCharSequenceArrayToStringArray(a.getTextArray(attr));
        }else if(attr == R.styleable.LoopView_npv_TextColorNormal){
            mTextColorNormal = a.getColor(attr, DEFAULT_TEXT_COLOR_NORMAL);
        }else if(attr == R.styleable.LoopView_npv_TextColorSelected){
            mTextColorSelected = a.getColor(attr, DEFAULT_TEXT_COLOR_SELECTED);
        }else if(attr == R.styleable.LoopView_npv_TextColorHint){
            mTextColorHint = a.getColor(attr, DEFAULT_TEXT_COLOR_SELECTED);
        }else if(attr == R.styleable.LoopView_npv_TextSizeNormal){
            mTextSizeNormal = a.getDimensionPixelSize(attr, sp2px(context, DEFAULT_TEXT_SIZE_NORMAL_SP));
        }else if(attr == R.styleable.LoopView_npv_TextSizeSelected){
            mTextSizeSelected = a.getDimensionPixelSize(attr, sp2px(context, DEFAULT_TEXT_SIZE_SELECTED_SP));
        }else if(attr == R.styleable.LoopView_npv_TextSizeHint){
            mTextSizeHint = a.getDimensionPixelSize(attr, sp2px(context, DEFAULT_TEXT_SIZE_HINT_SP));
        }else if(attr == R.styleable.LoopView_npv_MinValue){
            mMinShowIndex = a.getInteger(attr, 0);
        }else if(attr == R.styleable.LoopView_npv_MaxValue){
            mMaxShowIndex = a.getInteger(attr, 0);
        }else if(attr == R.styleable.LoopView_npv_WrapSelectorWheel){
            mWrapSelectorWheel = a.getBoolean(attr, DEFAULT_WRAP_SELECTOR_WHEEL);
        }else if(attr == R.styleable.LoopView_npv_ShowDivider){
            mShowDivider = a.getBoolean(attr, DEFAULT_SHOW_DIVIDER);
        }else if(attr == R.styleable.LoopView_npv_HintText){
            mHintText = a.getString(attr);
        }else if(attr == R.styleable.LoopView_npv_AlternativeHint){
            mAlterHint = a.getString(attr);
        }else if(attr == R.styleable.LoopView_npv_EmptyItemHint){
            mEmptyItemHint = a.getString(attr);
        }else if(attr == R.styleable.LoopView_npv_MarginStartOfHint){
            mMarginStartOfHint = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_MARGIN_START_OF_HINT_DP));
        }else if(attr == R.styleable.LoopView_npv_MarginEndOfHint){
            mMarginEndOfHint = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_MARGIN_END_OF_HINT_DP));
        }else if(attr == R.styleable.LoopView_npv_ItemPaddingVertical){
            mItemPaddingVertical = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_ITEM_PADDING_DP_V));
        }else if(attr == R.styleable.LoopView_npv_ItemPaddingHorizontal){
            mItemPaddingHorizontal = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_ITEM_PADDING_DP_H));
        }else if(attr == R.styleable.LoopView_npv_AlternativeTextArrayWithMeasureHint){
            mAlterTextArrayWithMeasureHint = a.getTextArray(attr);
        }else if(attr == R.styleable.LoopView_npv_AlternativeTextArrayWithoutMeasureHint){
            mAlterTextArrayWithoutMeasureHint = a.getTextArray(attr);
        }else if(attr == R.styleable.LoopView_npv_RespondChangeOnDetached){
            mRespondChangeOnDetach = a.getBoolean(attr, DEFAULT_RESPOND_CHANGE_ON_DETACH);
        }else if(attr == R.styleable.LoopView_npv_RespondChangeInMainThread){
            mRespondChangeInMainThread = a.getBoolean(attr, DEFAULT_RESPOND_CHANGE_IN_MAIN_THREAD);
        }else if (attr == R.styleable.LoopView_npv_TextEllipsize) {
            mTextEllipsize = a.getString(attr);
        }
    }
    a.recycle();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:69,代碼來源:PickerView.java

示例5: defaultInit

import android.content.res.TypedArray; //導入方法依賴的package包/類
private void defaultInit(Context context,AttributeSet attrs){
	TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.lingju);
	this.title=a.getString(R.styleable.lingju_item_title);
	this.list=a.getTextArray(R.styleable.lingju_array);
	/*int arrayRid=a.getInt(R.styleable.lingju_array, -1);
	Log.e("LingjuCheckListBox", "title="+title+",arrayID="+arrayRid);
	if(arrayRid>-1){
		this.list=context.getResources().getStringArray(arrayRid);
	}*/
	a.recycle();
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:12,代碼來源:LingjuCheckListBox.java

示例6: MyTabWidget

import android.content.res.TypedArray; //導入方法依賴的package包/類
public MyTabWidget(Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);

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

	// 讀取xml中,各個tab使用的文字
	mLabels = a.getTextArray(R.styleable.TabWidget_bottom_labels);
	//讀取xml中底部顯示圖片
	int resId = a.getResourceId(R.styleable.TabWidget_bottom_icon, 0);
	mIconTa = context.getResources().obtainTypedArray(resId);
	mTextColorStateList = a.getColorStateList(R.styleable.TabWidget_bottom_text_color);
	int attrResId = a.getResourceId(R.styleable.TabWidget_bottom_items_attr, 0);
	if (attrResId > 0) {
		mAttrTa = context.getResources().obtainTypedArray(attrResId);
	}
	if (null == mLabels || mLabels.length <= 0) {
		try {
			throw new BaseException("底部菜單的文字數組未添加...");
		} catch (BaseException e) {
			e.printStackTrace();
		} finally {
			LogUtils.i(MyTabWidget.class.getSimpleName() + " 出錯");
		}
		a.recycle();
		return;
	}

	a.recycle();

	// 初始化控件
	init(context);
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:34,代碼來源:MyTabWidget.java

示例7: getTextArray

import android.content.res.TypedArray; //導入方法依賴的package包/類
public static CharSequence[] getTextArray(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex) {
    CharSequence[] val = a.getTextArray(index);
    if (val == null) {
        return a.getTextArray(fallbackIndex);
    }
    return val;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:8,代碼來源:TypedArrayUtils.java

示例8: parseAttributes

import android.content.res.TypedArray; //導入方法依賴的package包/類
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();
}
 
開發者ID:alfredayibonte,項目名稱:QuestionnaireView,代碼行數:13,代碼來源:QuestionnaireView.java

示例9: handleAttrs

import android.content.res.TypedArray; //導入方法依賴的package包/類
/**
     * Handle the attributes
     * set the texts
     * set the timeout
     *
     * @param attrs provided attributes
     */
    private void handleAttrs(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.GmFadeTextView, defStyleAttr, defStyleRes);
//        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.fading_text_view);
        this.texts = a.getTextArray(R.styleable.GmFadeTextView_texts);
        this.sTexts = a.getText(R.styleable.GmFadeTextView_texts);
        this.timeout = Math.abs(a.getInteger(R.styleable.GmFadeTextView_timeout, 14500)) + getResources().getInteger(android.R.integer.config_longAnimTime);
        if (!TextUtils.isEmpty(sTexts)) {
            isSingleText = true;
        }
        a.recycle();
    }
 
開發者ID:goutham106,項目名稱:GmArchMvvm,代碼行數:19,代碼來源:GmFadeTextView.java

示例10: init

import android.content.res.TypedArray; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs) {
  suggestions = new ArrayList<>();
  mode = Mode.NORMAL;

  if (attrs != null) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AutoFillEditText);

    try {
      CharSequence[] suggestionsValue = a.getTextArray(R.styleable.AutoFillEditText_suggestions);
      String modeValue = a.getString(R.styleable.AutoFillEditText_mode);

      if (suggestionsValue != null) {
        for (CharSequence value : suggestionsValue) {
          suggestions.add(value.toString());
        }
      }

      if (modeValue != null && modeValue.equals("email")) {
        mode = Mode.EMAIL;
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      a.recycle();
    }
  }

  textFillStrategy = (mode == Mode.EMAIL)
      ? new EmailFillStrategy(this, suggestions)
      : new NormalTextFillStrategy(this, suggestions);
}
 
開發者ID:nntuyen,項目名稱:auto-fill-edit-text,代碼行數:32,代碼來源:AutoFillEditText.java

示例11: CircleRangeView

import android.content.res.TypedArray; //導入方法依賴的package包/類
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;
}
 
開發者ID:WangGanxin,項目名稱:CircleRangeView,代碼行數:43,代碼來源:CircleRangeView.java

示例12: ProWebView

import android.content.res.TypedArray; //導入方法依賴的package包/類
/**
 * @see WebView(Context, AttributeSet, int)
 */
public ProWebView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    init();
    scrollChildHelper = new NestedScrollingChildHelper(this);
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ProWebView);
    try {
        setAboutBlankHtml(array.getString(R.styleable.ProWebView_blankHtml));
        setHomeUrl(array.getString(R.styleable.ProWebView_home));
        CharSequence[] blacklist = array.getTextArray(R.styleable.ProWebView_blacklist);
        if (blacklist!=null) {
            for (CharSequence sequence : blacklist)
                this.blacklist.add(sequence.toString());
        }
        setPrivateBrowsingEnabled(array.getBoolean(R.styleable.ProWebView_privateMode, false));
        blockAds(array.getBoolean(R.styleable.ProWebView_blockAds, false));
        setGeolocationEnabled(array.getBoolean(R.styleable.ProWebView_locationEnabled, false));
        getSettings().setJavaScriptEnabled(array.getBoolean(R.styleable.ProWebView_javascriptEnabled, true));
        switch (array.getInt(R.styleable.ProWebView_locationMode, 1)){
            case 1:
                setLocationMode(LocationMode.MODE_BOTH);
                break;
            case 2:
                setLocationMode(LocationMode.MODE_FINE);
                break;
            case 3:
                setLocationMode(LocationMode.MODE_COARSE);
                break;
        }
        setCookiesEnabled(array.getBoolean(R.styleable.ProWebView_cookiesEnabled, true));
        if (Build.VERSION.SDK_INT>=21)
            setThirdPartyCookiesEnabled(array.getBoolean(R.styleable.ProWebView_thirdPartyCookiesEnabled, true));
        switch (array.getInt(R.styleable.ProWebView_cacheMode, 3)) {
            case 1:
                getSettings().setCacheMode(LOAD_CACHE_ELSE_NETWORK);
                break;
            case 2:
                getSettings().setCacheMode(LOAD_CACHE_ONLY);
                break;
            case 3:
                getSettings().setCacheMode(LOAD_DEFAULT);
                break;
            case 4:
                getSettings().setCacheMode(LOAD_NO_CACHE);
                break;
        }
        setNestedScrollingEnabled(array.getBoolean(R.styleable.ProWebView_nestedScrollingEnabled, true));
        String protocol = array.getString(R.styleable.ProWebView_defaultProtocol);
        if (protocol!=null)
            setDefaultProtocol(protocol);
    } finally {
        array.recycle();
    }
}
 
開發者ID:vic797,項目名稱:prowebview,代碼行數:57,代碼來源:ProWebView.java

示例13: HListView

import android.content.res.TypedArray; //導入方法依賴的package包/類
public HListView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.mHeaderViewInfos = new ArrayList();
    this.mFooterViewInfos = new ArrayList();
    this.mAreAllItemsSelectable = true;
    this.mItemsCanFocus = false;
    this.mTempRect = new Rect();
    this.loading_header = false;
    this.loading_footer = false;
    this.mLastSavedFirstVisibleItem = -1;
    this.mArrowScrollFocusResult = new ArrowScrollFocusResult(null);
    TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.HListView, defStyle, 0);
    CharSequence[] entries = null;
    Drawable dividerDrawable = null;
    Drawable overscrollHeader = null;
    Drawable overscrollFooter = null;
    int dividerWidth = 0;
    boolean headerDividersEnabled = true;
    boolean footerDividersEnabled = true;
    int measureWithChild = -1;
    if (array != null) {
        entries = array.getTextArray(0);
        dividerDrawable = array.getDrawable(1);
        overscrollHeader = array.getDrawable(5);
        overscrollFooter = array.getDrawable(6);
        dividerWidth = array.getDimensionPixelSize(2, 0);
        headerDividersEnabled = array.getBoolean(3, true);
        footerDividersEnabled = array.getBoolean(4, true);
        measureWithChild = array.getInteger(7, -1);
        array.recycle();
    }
    if (entries != null) {
        setAdapter(new ArrayAdapter(context, 17367043, entries));
    }
    if (dividerDrawable != null) {
        setDivider(dividerDrawable);
    }
    if (overscrollHeader != null) {
        setOverscrollHeader(overscrollHeader);
    }
    if (overscrollFooter != null) {
        setOverscrollFooter(overscrollFooter);
    }
    if (dividerWidth != 0) {
        setDividerWidth(dividerWidth);
    }
    this.mHeaderDividersEnabled = headerDividersEnabled;
    this.mFooterDividersEnabled = footerDividersEnabled;
    this.mMeasureWithChild = measureWithChild;
    setOnScrollListener(this);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:52,代碼來源:HListView.java

示例14: initAttr

import android.content.res.TypedArray; //導入方法依賴的package包/類
private void initAttr(Context context, AttributeSet attrs){
    if (attrs == null) {
        return;
    }
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NumberPickerView);
    int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);
        if(attr == R.styleable.NumberPickerView_npv_ShowCount){
            mShowCount = a.getInt(attr, DEFAULT_SHOW_COUNT);
        }else if(attr == R.styleable.NumberPickerView_npv_DividerColor){
            mDividerColor = a.getColor(attr, DEFAULT_DIVIDER_COLOR);
        }else if(attr == R.styleable.NumberPickerView_npv_DividerHeight){
            mDividerHeight = a.getDimensionPixelSize(attr, DEFAULT_DIVIDER_HEIGHT);
        }else if(attr == R.styleable.NumberPickerView_npv_DividerMarginLeft){
            mDividerMarginL = a.getDimensionPixelSize(attr, DEFAULT_DIVIDER_MARGIN_HORIZONTAL);
        }else if(attr == R.styleable.NumberPickerView_npv_DividerMarginRight){
            mDividerMarginR = a.getDimensionPixelSize(attr, DEFAULT_DIVIDER_MARGIN_HORIZONTAL);
        }else if(attr == R.styleable.NumberPickerView_npv_TextArray){
            mDisplayedValues = convertCharSequenceArrayToStringArray(a.getTextArray(attr));
        }else if(attr == R.styleable.NumberPickerView_npv_TextColorNormal){
            mTextColorNormal = a.getColor(attr, DEFAULT_TEXT_COLOR_NORMAL);
        }else if(attr == R.styleable.NumberPickerView_npv_TextColorSelected){
            mTextColorSelected = a.getColor(attr, DEFAULT_TEXT_COLOR_SELECTED);
        }else if(attr == R.styleable.NumberPickerView_npv_TextColorHint){
            mTextColorHint = a.getColor(attr, DEFAULT_TEXT_COLOR_SELECTED);
        }else if(attr == R.styleable.NumberPickerView_npv_TextSizeNormal){
            mTextSizeNormal = a.getDimensionPixelSize(attr, sp2px(context, DEFAULT_TEXT_SIZE_NORMAL_SP));
        }else if(attr == R.styleable.NumberPickerView_npv_TextSizeSelected){
            mTextSizeSelected = a.getDimensionPixelSize(attr, sp2px(context, DEFAULT_TEXT_SIZE_SELECTED_SP));
        }else if(attr == R.styleable.NumberPickerView_npv_TextSizeHint){
            mTextSizeHint = a.getDimensionPixelSize(attr, sp2px(context, DEFAULT_TEXT_SIZE_HINT_SP));
        }else if(attr == R.styleable.NumberPickerView_npv_MinValue){
            mMinShowIndex = a.getInteger(attr, 0);
        }else if(attr == R.styleable.NumberPickerView_npv_MaxValue){
            mMaxShowIndex = a.getInteger(attr, 0);
        }else if(attr == R.styleable.NumberPickerView_npv_WrapSelectorWheel){
            mWrapSelectorWheel = a.getBoolean(attr, DEFAULT_WRAP_SELECTOR_WHEEL);
        }else if(attr == R.styleable.NumberPickerView_npv_ShowDivider){
            mShowDivider = a.getBoolean(attr, DEFAULT_SHOW_DIVIDER);
        }else if(attr == R.styleable.NumberPickerView_npv_HintText){
            mHintText = a.getString(attr);
        }else if(attr == R.styleable.NumberPickerView_npv_AlternativeHint){
            mAlterHint = a.getString(attr);
        }else if(attr == R.styleable.NumberPickerView_npv_EmptyItemHint){
            mEmptyItemHint = a.getString(attr);
        }else if(attr == R.styleable.NumberPickerView_npv_MarginStartOfHint){
            mMarginStartOfHint = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_MARGIN_START_OF_HINT_DP));
        }else if(attr == R.styleable.NumberPickerView_npv_MarginEndOfHint){
            mMarginEndOfHint = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_MARGIN_END_OF_HINT_DP));
        }else if(attr == R.styleable.NumberPickerView_npv_ItemPaddingVertical){
            mItemPaddingVertical = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_ITEM_PADDING_DP_V));
        }else if(attr == R.styleable.NumberPickerView_npv_ItemPaddingHorizontal){
            mItemPaddingHorizontal = a.getDimensionPixelSize(attr, dp2px(context, DEFAULT_ITEM_PADDING_DP_H));
        }else if(attr == R.styleable.NumberPickerView_npv_AlternativeTextArrayWithMeasureHint){
            mAlterTextArrayWithMeasureHint = a.getTextArray(attr);
        }else if(attr == R.styleable.NumberPickerView_npv_AlternativeTextArrayWithoutMeasureHint){
            mAlterTextArrayWithoutMeasureHint = a.getTextArray(attr);
        }else if(attr == R.styleable.NumberPickerView_npv_RespondChangeOnDetached){
            mRespondChangeOnDetach = a.getBoolean(attr, DEFAULT_RESPOND_CHANGE_ON_DETACH);
        }else if(attr == R.styleable.NumberPickerView_npv_RespondChangeInMainThread){
            mRespondChangeInMainThread = a.getBoolean(attr, DEFAULT_RESPOND_CHANGE_IN_MAIN_THREAD);
        }else if (attr == R.styleable.NumberPickerView_npv_TextEllipsize) {
            mTextEllipsize = a.getString(attr);
        }
    }
    a.recycle();
}
 
開發者ID:huashengzzz,項目名稱:SmartChart,代碼行數:69,代碼來源:NumberPickerView.java

示例15: RangeSeekBar

import android.content.res.TypedArray; //導入方法依賴的package包/類
public RangeSeekBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray t = context.obtainStyledAttributes(attrs, R.styleable.RangeSeekBar);
    cellsCount = t.getInt(R.styleable.RangeSeekBar_cells, 1);
    reserveValue = t.getFloat(R.styleable.RangeSeekBar_reserve, 0);
    mMin = t.getFloat(R.styleable.RangeSeekBar_min, 0);
    mMax = t.getFloat(R.styleable.RangeSeekBar_max, 100);
    mThumbResId = t.getResourceId(R.styleable.RangeSeekBar_seekBarResId, 0);
    mProgressHintBGId = t.getResourceId(R.styleable.RangeSeekBar_progressHintResId, 0);
    colorLineSelected = t.getColor(R.styleable.RangeSeekBar_lineColorSelected, 0xFF4BD962);
    colorLineEdge = t.getColor(R.styleable.RangeSeekBar_lineColorEdge, 0xFFD7D7D7);
    colorPrimary = t.getColor(R.styleable.RangeSeekBar_thumbPrimaryColor, 0);
    colorSecondary = t.getColor(R.styleable.RangeSeekBar_thumbSecondaryColor, 0);
    mTextArray = t.getTextArray(R.styleable.RangeSeekBar_markTextArray);
    mHideProgressHint = t.getBoolean(R.styleable.RangeSeekBar_hideProgressHint,false);
    textPadding = (int)t.getDimension(R.styleable.RangeSeekBar_textPadding,dp2px(context,7));
    mTextSize = (int)t.getDimension(R.styleable.RangeSeekBar_textSize,dp2px(context,12));
    mHintBGHeight = t.getDimension(R.styleable.RangeSeekBar_hintBGHeight,0);
    mHintBGWith = t.getDimension(R.styleable.RangeSeekBar_hintBGWith,0);
    mSeekBarHeight = (int)t.getDimension(R.styleable.RangeSeekBar_seekBarHeight,dp2px(context,2));
    mHintBGPadding = (int)t.getDimension(R.styleable.RangeSeekBar_hintBGPadding,0);
    mThumbSize = (int)t.getDimension(R.styleable.RangeSeekBar_thumbSize,dp2px(context,26));
    mCellMode = t.getInt(R.styleable.RangeSeekBar_cellMode , 0);
    mSeekBarMode = t.getInt(R.styleable.RangeSeekBar_seekBarMode , 2);

    if (mSeekBarMode == 2){
        leftSB = new SeekBar(-1);
        rightSB = new SeekBar(1);
    }else {
        leftSB = new SeekBar(-1);
    }

    // if you don't set the mHintBGWith or the mHintBGWith < default value, if will use default value
    if (mHintBGWith == 0) {
        DEFAULT_PADDING_LEFT_AND_RIGHT = dp2px(context, 25);
    }else {
        DEFAULT_PADDING_LEFT_AND_RIGHT = Math.max((int)(mHintBGWith / 2+ dp2px(context, 5)),dp2px(context, 25));

    }

    setRules(mMin, mMax, reserveValue, cellsCount);
    initPaint();
    initBitmap();
    t.recycle();

    defaultPaddingTop = mSeekBarHeight / 2;

    mHintBGHeight = mHintBGHeight == 0 ? (mCursorPaint.measureText("國") * 3) : mHintBGHeight;
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:50,代碼來源:RangeSeekBar.java


注:本文中的android.content.res.TypedArray.getTextArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。