2011-03-11 117 views
0

當我有一個左/右圖像的TextView,我怎麼能改變它在運行時?我搜索了一下,發現了很多關於通過XML的方法,但在代碼中做的並不多。這是我試過的,但是這改變了整個textview背景。我正在嘗試更改imageview內容。如何在文本視圖中逐步更改ImageView圖像?

ImageView iv = new ImageView(getBaseContext()); 
iv.setBackgroundResource(R.drawable.newimage); 
Drawable d = iv.getBackground(); 
textView3.setBackgroundDrawable(d); 
+0

完成。道歉 - 忘了這麼做 – wufoo 2011-03-11 15:15:16

回答

2

沒關係 - 這樣做。

ImageView iv = new ImageView(getBaseContext()); 
iv.setBackgroundResource(R.drawable.redbg); 
Drawable d = iv.getBackground(); 
d.setBounds(0, 0, 50, 50); 
tv3.setCompoundDrawables(d, null, null, null);