开发者

android raw resource

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜