Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom resource folder name (e.g. res\drawable-gamepad)

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 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?

like image 808
dop2000 Avatar asked Nov 25 '25 04:11

dop2000


1 Answers

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

see the Link: Difference between /res and /assets directories


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!