Android从另一个按钮的图像设置一个图像按钮的图像

时间:2015-03-06 06:09:46

标签: android

我有两个图像按钮,现在我想从另一个按钮的图像设置一个按钮的图像。那么我怎么能成功地做到这一点?我需要先获取imageButton1的图像,然后将此图像设置为imageButton2。

ImageButton imageButton1=(ImageButton)this.findViewById(R.id.beans);
ImageButton imageButton2=(ImageButton)this.findViewById(R.id.imageButton);

2 个答案:

答案 0 :(得分:0)

使用 imageButton1.getDrawable() imageButton1.getBackground() 以获取ImageButton的图像。

答案 1 :(得分:0)

使用setTag()和getTag()来关联和检索ImageButton的自定义数据