运行getFields()方法时无法识别添加到可绘制文件夹中的图像 [英] Images added to drawable folder not being recognized when the getFields() method is run

查看:94
本文介绍了运行getFields()方法时无法识别添加到可绘制文件夹中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将720张新图像添加到 Drawable 文件夹中,但是当我使用 Field [] drawables = android.R.drawable.class.getFields()时,这些图像都无法识别; .

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();
        }
    }

这仅返回默认情况下添加到 Drawable 文件夹的图像列表.我还尝试了 getDeclaredFields ,但没有成功.

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

推荐答案

您需要使用自己生成的R类,即 your.package.name.R.drawable .

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

这篇关于运行getFields()方法时无法识别添加到可绘制文件夹中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆