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


Java Resources.obtainAttributes方法代碼示例

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


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

示例1: KeyboardRow

import android.content.res.Resources; //導入方法依賴的package包/類
public KeyboardRow(final Resources res, final KeyboardParams params,
        final XmlPullParser parser, final int y) {
    mParams = params;
    final TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
            R.styleable.Keyboard);
    mRowHeight = (int)ResourceUtils.getDimensionOrFraction(keyboardAttr,
            R.styleable.Keyboard_rowHeight, params.mBaseHeight, params.mDefaultRowHeight);
    keyboardAttr.recycle();
    final TypedArray keyAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
            R.styleable.Keyboard_Key);
    mRowAttributesStack.push(new RowAttributes(
            keyAttr, params.mDefaultKeyWidth, params.mBaseWidth));
    keyAttr.recycle();

    mCurrentY = y;
    mCurrentX = 0.0f;
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:18,代碼來源:KeyboardRow.java

示例2: parseAuthenticatorDescription

import android.content.res.Resources; //導入方法依賴的package包/類
private static AuthenticatorDescription parseAuthenticatorDescription(Resources resources, String packageName,
																	  AttributeSet attributeSet) {
	TypedArray array = resources.obtainAttributes(attributeSet, R_Hide.styleable.AccountAuthenticator.get());
	try {
		String accountType = array.getString(R_Hide.styleable.AccountAuthenticator_accountType.get());
		int label = array.getResourceId(R_Hide.styleable.AccountAuthenticator_label.get(), 0);
		int icon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_icon.get(), 0);
		int smallIcon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_smallIcon.get(), 0);
		int accountPreferences = array.getResourceId(R_Hide.styleable.AccountAuthenticator_accountPreferences.get(), 0);
		boolean customTokens = array.getBoolean(R_Hide.styleable.AccountAuthenticator_customTokens.get(), false);
		if (TextUtils.isEmpty(accountType)) {
			return null;
		}
		return new AuthenticatorDescription(accountType, packageName, label, icon, smallIcon, accountPreferences,
				customTokens);
	} finally {
		array.recycle();
	}
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:20,代碼來源:VAccountManagerService.java

示例3: parseAuthenticatorDescription

import android.content.res.Resources; //導入方法依賴的package包/類
private static AuthenticatorDescription parseAuthenticatorDescription(Resources resources, String packageName,
                                                                      AttributeSet attributeSet) {
    TypedArray array = resources.obtainAttributes(attributeSet, R_Hide.styleable.AccountAuthenticator.get());
    try {
        String accountType = array.getString(R_Hide.styleable.AccountAuthenticator_accountType.get());
        int label = array.getResourceId(R_Hide.styleable.AccountAuthenticator_label.get(), 0);
        int icon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_icon.get(), 0);
        int smallIcon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_smallIcon.get(), 0);
        int accountPreferences = array.getResourceId(R_Hide.styleable.AccountAuthenticator_accountPreferences.get(), 0);
        boolean customTokens = array.getBoolean(R_Hide.styleable.AccountAuthenticator_customTokens.get(), false);
        if (TextUtils.isEmpty(accountType)) {
            return null;
        }
        return new AuthenticatorDescription(accountType, packageName, label, icon, smallIcon, accountPreferences,
                customTokens);
    } finally {
        array.recycle();
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:20,代碼來源:VAccountManagerService.java

示例4: parseAuthenticatorDescription

import android.content.res.Resources; //導入方法依賴的package包/類
private static AuthenticatorDescription parseAuthenticatorDescription(Resources resources, String packageName,
		AttributeSet attributeSet) {
	TypedArray array = resources.obtainAttributes(attributeSet, R_Hide.styleable.AccountAuthenticator.get());
	try {
		String accountType = array.getString(R_Hide.styleable.AccountAuthenticator_accountType.get());
		int label = array.getResourceId(R_Hide.styleable.AccountAuthenticator_label.get(), 0);
		int icon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_icon.get(), 0);
		int smallIcon = array.getResourceId(R_Hide.styleable.AccountAuthenticator_smallIcon.get(), 0);
		int accountPreferences = array.getResourceId(R_Hide.styleable.AccountAuthenticator_accountPreferences.get(), 0);
		boolean customTokens = array.getBoolean(R_Hide.styleable.AccountAuthenticator_customTokens.get(), false);
		if (TextUtils.isEmpty(accountType)) {
			return null;
		}
		return new AuthenticatorDescription(accountType, packageName, label, icon, smallIcon, accountPreferences,
				customTokens);
	} finally {
		array.recycle();
	}
}
 
開發者ID:codehz,項目名稱:container,代碼行數:20,代碼來源:VAccountManagerService.java

示例5: obtainAttributes

import android.content.res.Resources; //導入方法依賴的package包/類
static TypedArray obtainAttributes(
        Resources res, Resources.Theme theme, AttributeSet set, int[] attrs) {
    if (theme == null) {
        return res.obtainAttributes(set, attrs);
    }
    return theme.obtainStyledAttributes(set, attrs, 0, 0);
}
 
開發者ID:Pingsh,項目名稱:Mix,代碼行數:8,代碼來源:DrawableUtils.java

示例6: inflate

import android.content.res.Resources; //導入方法依賴的package包/類
void inflate(@NonNull final Resources r, @NonNull final AttributeSet attrs) {
    final TypedArray a = r.obtainAttributes(attrs, R.styleable.ParticlesView);
    try {
        handleAttrs(a);
    } finally {
        a.recycle();
    }
}
 
開發者ID:Doctoror,項目名稱:ParticlesDrawable,代碼行數:9,代碼來源:SceneController.java

示例7: parseSyncAdapterType

import android.content.res.Resources; //導入方法依賴的package包/類
private SyncAdapterType parseSyncAdapterType(Resources res, AttributeSet set) {
    TypedArray obtainAttributes = res.obtainAttributes(set, R_Hide.styleable.SyncAdapter.get());
    try {
        String contentAuthority = obtainAttributes.getString(R_Hide.styleable.SyncAdapter_contentAuthority.get());
        String accountType = obtainAttributes.getString(R_Hide.styleable.SyncAdapter_accountType.get());
        if (contentAuthority == null || accountType == null) {
            obtainAttributes.recycle();
            return null;
        }
        boolean userVisible = obtainAttributes.getBoolean(R_Hide.styleable.SyncAdapter_userVisible.get(), true);
        boolean supportsUploading = obtainAttributes.getBoolean(R_Hide.styleable.SyncAdapter_supportsUploading.get(), true);
        boolean isAlwaysSyncable = obtainAttributes.getBoolean(R_Hide.styleable.SyncAdapter_isAlwaysSyncable.get(), true);
        boolean allowParallelSyncs = obtainAttributes.getBoolean(R_Hide.styleable.SyncAdapter_allowParallelSyncs.get(), true);
        String settingsActivity = obtainAttributes.getString(R_Hide.styleable.SyncAdapter_settingsActivity.get());
        SyncAdapterType type;
        if (SyncAdapterTypeN.ctor != null) {
            type = SyncAdapterTypeN.ctor.newInstance(contentAuthority, accountType, userVisible, supportsUploading, isAlwaysSyncable, allowParallelSyncs, settingsActivity, null);
            obtainAttributes.recycle();
            return type;
        }
        type = mirror.android.content.SyncAdapterType.ctor.newInstance(contentAuthority, accountType, userVisible, supportsUploading, isAlwaysSyncable, allowParallelSyncs, settingsActivity);
        obtainAttributes.recycle();
        return type;
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:29,代碼來源:VContentService.java

示例8: inflate

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public void inflate(@NonNull final Resources r,
                    @NonNull final XmlPullParser parser,
                    @NonNull final AttributeSet attrs,
                    @Nullable final Resources.Theme theme) throws XmlPullParserException, IOException {
    super.inflate(r, parser, attrs, theme);
    final TypedArray a = r.obtainAttributes(attrs, R.styleable.ParticlesDrawable);
    try {
        handleAttrs(a);
    } finally {
        a.recycle();
    }
}
 
開發者ID:dsa28s,項目名稱:TimeSkyBackground,代碼行數:14,代碼來源:ParticlesDrawable.java

示例9: readScriptIdFromTagFeature

import android.content.res.Resources; //導入方法依賴的package包/類
private static int readScriptIdFromTagFeature(final Resources resources,
        final XmlPullParser parser) throws IOException, XmlPullParserException {
    final TypedArray featureAttr = resources.obtainAttributes(Xml.asAttributeSet(parser),
            R.styleable.KeyboardLayoutSet_Feature);
    try {
        final int scriptId =
                featureAttr.getInt(R.styleable.KeyboardLayoutSet_Feature_supportedScript,
                        ScriptUtils.SCRIPT_UNKNOWN);
        XmlParseUtils.checkEndTag(TAG_FEATURE, parser);
        return scriptId;
    } finally {
        featureAttr.recycle();
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:15,代碼來源:KeyboardLayoutSet.java

示例10: obtainAttributes

import android.content.res.Resources; //導入方法依賴的package包/類
static TypedArray obtainAttributes(Resources res, Theme theme, AttributeSet set, int[] attrs) {
    if (theme == null) {
        return res.obtainAttributes(set, attrs);
    }
    return theme.obtainStyledAttributes(set, attrs, 0, 0);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:7,代碼來源:VectorDrawableCommon.java

示例11: inflate

import android.content.res.Resources; //導入方法依賴的package包/類
public void inflate(Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException {
    if (this.mDelegateDrawable != null) {
        DrawableCompat.inflate(this.mDelegateDrawable, res, parser, attrs, theme);
        return;
    }
    int eventType = parser.getEventType();
    while (eventType != 1) {
        if (eventType == 2) {
            String tagName = parser.getName();
            TypedArray a;
            if (ANIMATED_VECTOR.equals(tagName)) {
                a = obtainAttributes(res, theme, attrs, AndroidResources.styleable_AnimatedVectorDrawable);
                int drawableRes = a.getResourceId(0, 0);
                if (drawableRes != 0) {
                    VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(res, drawableRes, theme);
                    vectorDrawable.setAllowCaching(false);
                    vectorDrawable.setCallback(this.mCallback);
                    if (this.mAnimatedVectorState.mVectorDrawable != null) {
                        this.mAnimatedVectorState.mVectorDrawable.setCallback(null);
                    }
                    this.mAnimatedVectorState.mVectorDrawable = vectorDrawable;
                }
                a.recycle();
            } else if (TARGET.equals(tagName)) {
                a = res.obtainAttributes(attrs, AndroidResources.styleable_AnimatedVectorDrawableTarget);
                String target = a.getString(0);
                int id = a.getResourceId(1, 0);
                if (id != 0) {
                    if (this.mContext != null) {
                        setupAnimatorsForTarget(target, AnimatorInflater.loadAnimator(this.mContext, id));
                    } else {
                        throw new IllegalStateException("Context can't be null when inflating animators");
                    }
                }
                a.recycle();
            } else {
                continue;
            }
        }
        eventType = parser.next();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:43,代碼來源:AnimatedVectorDrawableCompat.java


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