本文整理匯總了Java中android.support.annotation.IntegerRes類的典型用法代碼示例。如果您正苦於以下問題:Java IntegerRes類的具體用法?Java IntegerRes怎麽用?Java IntegerRes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IntegerRes類屬於android.support.annotation包,在下文中一共展示了IntegerRes類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBindViewHolder
import android.support.annotation.IntegerRes; //導入依賴的package包/類
public void onBindViewHolder(final DataSource item) {
super.onBindViewHolder();
mTitleView.setText(item.getHeader());
mBodyView.setText(item.getDescription());
@IntegerRes
int actionLabel = item.getActionLabel();
if (actionLabel != 0) {
mActionView.setText(actionLabel);
mActionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
item.performAction(v.getContext());
}
});
mActionView.setVisibility(View.VISIBLE);
} else {
mActionView.setVisibility(View.GONE);
}
}
示例2: getInteger
import android.support.annotation.IntegerRes; //導入依賴的package包/類
/**
* Return an integer associated with a particular resource key.
* This resource can come from resources you provided via the URL or via default resources.
*
* @param key The desired resource key.
* @return Returns the integer value contained in the resource.
* @throws NotFoundException Throws NotFoundException if the given key does not exist.
*/
public int getInteger(@NonNull String key) throws NotFoundException {
Resource resource = resources.get(key);
if (null != resource && null != resource.getAsInt()) {
return resource.getAsInt();
}
@IntegerRes int resId = getApplicationResourceIdentifier(key, "integer");
if (0 != resId) {
int value = context.getResources().getInteger(resId);
resources.add(key, new Resource(value));
return value;
}
throw new NotFoundException("Integer resource with key: " + key);
}
示例3: onBindViewHolder
import android.support.annotation.IntegerRes; //導入依賴的package包/類
public void onBindViewHolder(final DataSource item) {
super.onBindViewHolder();
mTitleView.setText(item.getHeader());
mBodyView.setText(item.getDescription());
@IntegerRes
int actionLabel = item.getActionLabel();
if (actionLabel != 0) {
mActionView.setText(actionLabel);
mActionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SuggestionsMetrics.recordCardActionTapped();
item.performAction(v.getContext());
}
});
mActionView.setVisibility(View.VISIBLE);
} else {
mActionView.setVisibility(View.GONE);
}
}
示例4: getInteger
import android.support.annotation.IntegerRes; //導入依賴的package包/類
@Override
public int getInteger(@IntegerRes int id) throws NotFoundException {
int realId = getCorrespondResId(id);
if (realId > 0) {
return mSkinResources.getInteger(realId);
}
return super.getInteger(id);
}
示例5: getInteger
import android.support.annotation.IntegerRes; //導入依賴的package包/類
static int getInteger(Context context,
TypedArray array,
@StyleableRes int attr,
@IntegerRes int defaultIntRes) {
return array.getInteger(
attr, context.getResources().getInteger(defaultIntRes));
}
示例6: setBackgroundGradient
import android.support.annotation.IntegerRes; //導入依賴的package包/類
public void setBackgroundGradient(@IntegerRes int i, @IntegerRes int ii, @IntegerRes int iii) {
mSkyTime = Time.CUSTOM;
mDrawables[0] = i;
mDrawables[1] = ii;
mDrawables[2] = iii;
}
示例7: getLongPreference
import android.support.annotation.IntegerRes; //導入依賴的package包/類
public long getLongPreference(String name, @IntegerRes int res) {
long defaultValue = getResources().getInteger(res);
try {
return Long.parseLong(getPreferences().getString(name,String.valueOf(defaultValue)));
} catch (NumberFormatException e) {
return defaultValue;
}
}
示例8: getInteger
import android.support.annotation.IntegerRes; //導入依賴的package包/類
/**
* Get an integer from preferences
*
* @param context application context
* @param key preference key
* @param defaultValue default value
* @return integer
*/
public static int getInteger(@NonNull Context context, @StringRes int key, @IntegerRes int defaultValue) {
SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREFS_NAME, Context.MODE_PRIVATE);
String integerAsString = sharedPreferences.getString(context.getString(key), null);
if (integerAsString == null) {
return context.getResources().getInteger(defaultValue);
} else {
return Integer.valueOf(integerAsString);
}
}
示例9: changeBitmapColor
import android.support.annotation.IntegerRes; //導入依賴的package包/類
/**
* 給bitmap著色
* @param sourceBitmap
* @param color rgb
* @return
*/
public static Bitmap changeBitmapColor(@NonNull Bitmap sourceBitmap, @IntegerRes int color) {
Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0,
sourceBitmap.getWidth() - 1, sourceBitmap.getHeight() - 1);
Paint p = new Paint();
ColorFilter filter = new LightingColorFilter(color, 1);
p.setColorFilter(filter);
Canvas canvas = new Canvas(resultBitmap);
canvas.drawBitmap(resultBitmap, 0, 0, p);
return resultBitmap;
}
示例10: getLongPreference
import android.support.annotation.IntegerRes; //導入依賴的package包/類
public long getLongPreference(String name, @IntegerRes int res) {
long defaultValue = getResources().getInteger(res);
try {
return Long.parseLong(getPreferences().getString(name,String.valueOf(defaultValue)));
} catch (NumberFormatException e) {
return defaultValue;
}
}
示例11: getLongPreference
import android.support.annotation.IntegerRes; //導入依賴的package包/類
public long getLongPreference(String name, @IntegerRes int res) {
long defaultValue = getResources().getInteger(res);
try {
return Long.parseLong(getPreferences().getString(name, String.valueOf(defaultValue)));
} catch (NumberFormatException e) {
return defaultValue;
}
}
示例12: duration
import android.support.annotation.IntegerRes; //導入依賴的package包/類
protected int duration(@IntegerRes int resource){
return getResources().getInteger(resource);
}
示例13: withPlaceholder
import android.support.annotation.IntegerRes; //導入依賴的package包/類
public Builder withPlaceholder(@IntegerRes Integer placeholderRes) {
this.placeholderRes = placeholderRes;
return this;
}
示例14: getInteger
import android.support.annotation.IntegerRes; //導入依賴的package包/類
public int getInteger(@IntegerRes int id) {
return getResources().getInteger(id);
}
示例15: integer
import android.support.annotation.IntegerRes; //導入依賴的package包/類
public static int integer(@IntegerRes int resId) {
return sContext.getResources().getInteger(resId);
}