开发者

android raw resource

开发者 https://www.devze.com 2023-02-05 02:41 出处:网络
is t开发者_StackOverflowhere any way to get the file names stored in the res/raw folder programmatically?Why do you need that? Usually that\'s not a good idea and indicates that you have to work on yo

is t开发者_StackOverflowhere any way to get the file names stored in the res/raw folder programmatically?


Why do you need that? Usually that's not a good idea and indicates that you have to work on your apps design. Probably you'd better store your images at /assets folder or have an additional xml listing all of them. Anyhow here is an example how you can do that foe res/drawables folder. So implementing that for res/raw is as simple as:

Field[] raw = R.raw.class.getFields();
for (Field r : raw) {
    try {
        System.out.println("R.raw." + r.getName());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号