Hello All;
I want to to enter myImage image to every different value that variable 'kare' takes.
Th values of the ImageViews are like a8,b8, c8... etc (the coordinates of a chess board).
The question is how to get these id's from a variable like the code below. Unfortunately with the code below
the line that reads "ImageView ll = (ImageView) findViewById(R.drawable.kare);" gives an error with 'kare' highlighted as Red.
Thank you in advance....

pozisyonKlasi hamleGonder = new pozisyonKlasi();
        String[][][] gelPozisyon = pozisyonKlasi.pozisyon;
        for (int i = 0; i < 12; i++) {
            for (int j = 0; j < gelPozisyon[denm3][0].length; j++) {
                String kare = gelPozisyon[denm3][0][j];  //my variable
                ImageView ll = (ImageView) findViewById(R.drawable.kare);
                ll.setBackgroundResource(R.drawable.myImage);

Your error is not when setting the image, is getting the ImageView object.

R.drawable.kare is not the ImageView Id, it's a drawable.

If you get the ImageView correcly then you can use setBackgroundDrawable or setImageBitmap instead of setBackgroundResource.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.