如何设置通过code中的drawableRight资源? [英] How can I set the drawableRight resource via code?

查看:154
本文介绍了如何设置通过code中的drawableRight资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在右边我的按钮设置图像的按钮被点击后。我想通过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.

我已经看到了如何改变通过code中的背景资源,但我无法找到展示如何通过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?

推荐答案

您需要使用

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

方法,空任何不需要的。

method with null for any that are not needed.

这篇关于如何设置通过code中的drawableRight资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆