【发布时间】:2018-04-01 19:01:36
【问题描述】:
说,ImageView i1 中有一个图像,我想将 ImageView i1 复制到 ImageView i2,而不仅仅是将 i2 引用到 i1,而是实际复制。
ImageView i2 = new ImageView(context);
i2 = i1; //i2 only refers to i1
如果有一个类并且我们将 ImageView 作为其构造函数的参数传递
public class CopyEx{
public ImageView i2;
public CopyEx(ImageView i, Context c){
i2 = new ImageView(c);
i2 = i; //This also only refers to i and not copy it
}
}
似乎唯一有效的事情就是做
i2.setImageDrawable(i1.getDrawable());
and
i2.setTag(i1.getTag());
那么有没有办法复制一个 ImageView 呢?
【问题讨论】:
标签: java android imageview clone deep-copy