public static void applyMultiIconTo ( Drawable icon , int iconColor , Drawable selectedIcon , int selectedIconColor , boolean tinted , ImageView imageView ) { //if we have an icon then we want to set it if ( icon != null ) { //if we got a different color for the selectedIcon we need a StateList if ( selectedIcon != null ) { if ( tinted ) { imageView . setImageDrawable ( new PressedEffectStateListDrawable ( icon , selectedIcon , iconColor , selectedIconColor ) ) ; } else { imageView . setImageDrawable ( UIUtils . getIconStateList ( icon , selectedIcon ) ) ; } } else if ( tinted ) { imageView . setImageDrawable ( new PressedEffectStateListDrawable ( icon , iconColor , selectedIconColor ) ) ; } else { imageView . setImageDrawable ( icon ) ; } //make sure we display the icon imageView . setVisibility ( View . VISIBLE ) ; } else { //hide the icon imageView . setVisibility ( View . GONE ) ; } }
a small static helper to set a multi state drawable on a view