Android drawables : Is there any way to somehow link the int IDs to the R drawable IDs?
问题 I have 718 drawables in the drawable-mdpi , drawable-hdpi and drawable-xhdpi folders, whose names are 1.png, 2.png... to 718.png. (They are actually Pokémon sprites) So, depending on the Pokémon, I want to load one of them to show it. However, I cannot use the number to directly identify the R drawable ID. Is there any way (besides of a 718-case switch or a Hashmap<Integer,Integer> ) to somehow link the int IDs to the R drawable IDs? 回答1: You could try: String sprite = "drawable/"+number; int