我在我的应用程序中加载图像。我一直在使用带有图像的Enum,但是我已经读过某个地方,使用枚举并不是内存明智所以将它们存储为TypedArrays并将其作为数组在我的适配器中检索它会更好吗?
枚举类
public enum TeamLogos {
ONE(R.drawable.t1),
TWO(R.drawable.t2),
THREE(R.drawable.t3),
FOUR(R.drawable.t4),
FIVE(R.drawable.t5),
SIX(R.drawable.t6),
SEVEN(R.drawable.t7),
EIGHT(R.drawable.t8),
NINE(R.drawable.t9),
TEN(R.drawable.t10),
ELEVEN(R.drawable.t11),
TWELVE(R.drawable.t12),
THIRTEEN(R.drawable.t13),
FOURTEEN(R.drawable.t14),
FIFTEEN(R.drawable.t15),
SIXTEEN(R.drawable.t16),
SEVENTEEN(R.drawable.t17),
EIGHTEEN(R.drawable.t18),
NINETEEN(R.drawable.t21),
TWEENTY(R.drawable.t22),
TWENTYONE(R.drawable.t23),
TWENTYTWO(R.drawable.t24),
TWENTYTHREE(R.drawable.t25),
TWENTYFOUR(R.drawable.t26),
TWENTYFIVE(R.drawable.t27),
TWENTYSIX(R.drawable.t28),
TWENTYSEVEN(R.drawable.t29),
TWENTYEIGHT(R.drawable.unkown),
TWENTYNINE(R.drawable.t30);
private static final String TAG = "Avatar";
private final int mResId;
TeamLogos(@DrawableRes final int resId) {
mResId = resId;
}
@DrawableRes
public int getDrawableId() {
return mResId;
}
在我的适配器中重新启动它们
private static final TeamLogos[] mTeamLogos = TeamLogos.values();
设置drawable
left.setCompoundDrawablesWithIntrinsicBounds(0, mTeamLogos[childObject.getHomeIcon()].getDrawableId(), 0, 0);