Как я могу получить значение int "icon" из массива значений Int на примере:
2 = R.drawable.ic_blue?
или: как получить: R.drawable.ic_blue? зная идентификатор: 2?
public class iconsList {
public class IntValues {
public int id;
public int icon;
public IntValues(int id, int icon){
this.id=id;
this.icon=icon;
}
}
IntValues[] icons = new IntValues[] {
new IntValues(0, R.drawable.ic_default),
new IntValues(1, R.drawable.ic_red),
new IntValues(2, R.drawable.ic_blue),
};
}




Добавьте этот метод в свой класс iconsList
public IntValues find(int num) {
for (int i = 0; i < icons.length; i++) {
if (num == icons[i].icon) {
return icons[i];
}
}
return null;
}
Вы можете вернуть индекс ( i ) или класс IntValues с идентификатором ..
вы можете зацикливаться от 0 индекса до конца.