Images added to drawable folder not being recognized when the getFields() method is run

邮差的信 提交于 2021-02-10 08:48:26

问题


I have added 720 new images to my Drawable folder, but none of them are being recognized when I use Field[] drawables = android.R.drawable.class.getFields(); .

Field[] drawables = android.R.drawable.class.getFields();
    for (Field f : drawables) {
        try {
            System.out.println("R.drawable." + f.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

This just returns a list of the images added by default to the Drawable folder. I also tried getDeclaredFields but no success.


回答1:


You need to use your own generated R class, that's your.package.name.R.drawable.



来源:https://stackoverflow.com/questions/41595859/images-added-to-drawable-folder-not-being-recognized-when-the-getfields-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!