Android,如何以编程方式将图标*和*文本添加到按钮?

Mar*_*coS 2 icons android text button

我需要在Android应用中的代码(不是xml)中为按钮添加图标一些文本.

图标(库存图标,"expander_open_holo_light.9.png")应位于左侧,文本位于右侧.

我找不到任何线索......

hoo*_*d82 9

看一下setCompoundDrawableWithIntrinsicBounds().你可以在这里找到信息:

http://developer.android.com/reference/android/widget/TextView.html#setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)

基本上,这是以编程方式设置按钮的android:drawableLeft属性的方法.