views:

741

answers:

2

Hi,

There are several custom-made graphic objects (.png files) included in the project inside res/drawable map.

All elements are normally loaded and displayed in the user interface except two icons and so far haven't figured out what causes the problem.

The code which doesn't affect the user interface as it should is the following:

if (settings.isMute()) {
        muteIcon.setIconImage(R.drawable.ic_volume_off_small);
    } else {
        muteIcon.setIconImage(R.drawable.ic_volume_small);
    }

In both cases there is only ic_volume_small displayed on the screen and the Variables window in the IDE displays the following:

R.drawable.ic_volume_small = Class not loaded : net.client.android.R$drawable R.drawable.ic_volume_of_small = Class not loaded : net.client.android.R$drawable

The method (member of IconImage class) which should change the icon image is the following:

public void setIconImage(int imageFromResources) {
    iconImage = BitmapFactory.decodeResource(getResources(), imageFromResources);
    iconWidth = iconImage.getWidth();
    iconHeight = iconImage.getHeight();
    invalidate();

}

Does anyone know what could cause the described problem?

Thanks!

+1  A: 

Assuming what you want is the drawable from the Android framework and not your own, you'd want to use:

android.R.drawable.ic_volumne_off_small

rather than

R.drawable.ic_volume_off_small

(notice the android prefix).

JRL
I do want to use my own custom resources
niko
Are you importing Android.R in your java file? It could hide your own R file if that is the case.
JRL
A: 

If you recently added file, please refresh (press F5) the drawable directory and R is going to be generated again. Once R is regenerated, you can use the newly added resource.

Burcu Dogan