android source

res > mipmap > filename 읽기

리오파파 2024. 12. 10. 13:18

 

Field[] fields = R.mipmap.class.getDeclaredFields();
int image_max = 0;

for (Field field : fields) {
    try {
        int resId = field.getInt(null);
        String resourceName = context.getResources().getResourceName(resId);
        if (resourceName.contains("i_")) {  // card image names are i_nnnn.png
            image_max++;
        }
    } catch (IllegalAccessException | Resources.NotFoundException e) {
        e.printStackTrace();
    }
}