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));
}
The easiest way would be to create a new directory, say resdrawable-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 resdrawablecontrols.jpg and resdrawable-gamepadcontrols.jpg). But I'm guessing this is not possible.
Is there any other easy way to add alternate resources to the existing project?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…