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

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

问题描述

我试图在单击按钮后在按钮的右侧设置图像.我想通过代码来做到这一点.

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?

推荐答案

您需要使用

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

任何不需要的方法都为 null.

method with null for any that are not needed.

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

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