2011-03-11 80 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);