【发布时间】:2013-03-27 17:11:43
【问题描述】:
我想在运行时将按钮的文本更改为图像,然后在某些用户交互时返回(而不是我想要文本返回的图像)。 我怎样才能做到这一点?谁能给我举个例子?
据我了解,我无法使用图像按钮,因为我无法在其上添加文本。 我试过用
setCompoundDrawables
但这对我不起作用(按钮上没有可见的变化)。这是我的代码:
Button button = (Button) findViewById(R.id.button1);
Drawable myDrawable = this.getResources().getDrawable(R.drawable.ic_launcher);
myDrawable.setBounds(0, 0, 0, 0);
button.setCompoundDrawables(myDrawable, null, null, null);
请帮忙
【问题讨论】: