本文整理匯總了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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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();
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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();
}
}