Search code examples
androidbuttondrawable

How can I set the drawableRight resource via code?


I am trying to set an image on the right side of my button after the button has been clicked. I want to do this via code.

I have seen how to change the background resource via code but I am not able to find any examples showing how to change the sides via code. Is it possible?


Solution

  • You need to use the

    public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, 
     Drawable bottom)
    

    method with null for any that are not needed.