Problem with android Image

In fact, I have 52 images, which are mostly cards. image names from 1 to 52.

when I put all 52 images in my drawing folder, then it shows an error in a file R.javathat:

Syntax error on the token "image name (any between 1 and 52)", invalid VariableDeclaratorId

what is the problem?


thanks for the answer.

I think I had no problem.

I gave a name to my cards from 1 to 52, because I need to randomly select one card from it.

+3
source share
3 answers

Java. card1 card52 ( ).

EDITED TO ADD: , . ( ) , Bitmap[] cardImages = new Bitmap[52]; , , ,

Resources r = context.getResources();
cardImages[0] = loadBitmap(r.getDrawable(R.drawable.card1));
// ...
cardImages[12] = loadBitmap(r.getDrawable(R.drawable.card13));
// ...    
cardImages[51] = loadBitmap(r.getDrawable(R.drawable.card52));
+1

, Android

+1

. Android R , int , . . ints ids .

The problem is that Java does not allow the vairable name to start with a number. Your images start with a number, so your variables in the R file start with a number. You must choose a different name for your images.

+1
source

Source: https://habr.com/ru/post/1755970/


All Articles