views:

58

answers:

2

Hi,

I have created a method updateGUI() which include the following method calls:

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

Where setIconImage() is defined the following way:

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

}

While running this code the icon image doesn't change as it should. There are both images stored in the res/drawable directory but the ic_volume_off_small does never appear. Does anyone know what could be changed here in order the program works as it should?

Thank you!

A: 

That is a base class of of MuteIcon? If it something like ImageView, you should call method of super class to actually update image.

Nikolay Ivanov
A: 

If those are methods of a View child you have to override the View.onDraw() method to tell the system how to draw the image stored in iconImage after invalidate it.

If you are extending ImageView for muteIcon you can directly use or override ImageView.setImageResource(resource).

Jaime Soriano