自定义资源文件夹的名称(如水库\绘制,手柄) [英] Custom resource folder name (e.g. res\drawable-gamepad)

查看:126
本文介绍了自定义资源文件夹的名称(如水库\绘制,手柄)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加入游戏手柄的支持我的比赛。我需要大量的资源(字符串,可绘制)具体到游戏手柄。一个手柄资源指定一个不同的名称不是很有效,因为我已经写了很多code是这样的:

I'm adding gamepad support to my game. I need a lot of resources (strings, drawables) specific to gamepad. Specifying a different name for a gamepad resource is not very efficient, as I have to write a lot of code like this:

if (gamepadDetected) {
   image.setImageDrawable(getResources().getDrawable(R.drawable.controls_gamepad));
} else {
   image.setImageDrawable(getResources().getDrawable(R.drawable.controls_touch));
}

最简单的方法是创建一个新的目录,说资源\绘制-手柄,并以某种方式指示的Andr​​oid使用的资源从该文件夹时,我的游戏手柄检测。 这样一来,我可以使用相同的名称资源(比如资源\绘制\ controls.jpg 水库\绘制,手柄\ controls.jpg )。但我猜这是不可能的。

The easiest way would be to create a new directory, say res\drawable-gamepad and somehow instruct Android to use resources from this folder when my game detects gamepad. This way I could use the same names for resources (say res\drawable\controls.jpg and res\drawable-gamepad\controls.jpg). But I'm guessing this is not possible.

有没有其他简单的方法来替代资源添加到现有的项目?

Is there any other easy way to add alternate resources to the existing project?

推荐答案

custoum文件夹中不支持的资源文件夹,但你自己的文件夹结构,你可以使用的资产文件夹。

custoum folders are not supported in the res folder but you can use the assets folder for you own folder structure.

见链接:<一href="http://stackoverflow.com/questions/5583608/difference-between-res-and-assets-directories">Difference / RES和/资产目录之间

这篇关于自定义资源文件夹的名称(如水库\绘制,手柄)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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