我想在运行时将按钮的文本更改为图像,然后在某些用户交互中返回(而不是我想要文本返回的图像)。我怎样才能做到这一点?谁能给我一个例子?
据我了解,我无法使用图像按钮,因为我无法在其上添加文本。我试着用
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);
请帮忙