Android – 拖放ImageView的副本

Android – 拖放ImageView的副本,第1张

概述如何在Drad和Drop上创建 ImageView的副本?我在谷歌搜索,但我什么都没发现. 请帮我. Here’s一个完整的例子似乎可以完成您想要做的大部分工作.似乎唯一需要做的更改是创建一个新的ImageView并将位图复制到其中.为此,您需要将类MyDragListener的onDrag()方法更改为如下所示: case DragEvent.ACTION_DROP: // Droppe 如何在Drad和Drop上创建 ImageVIEw的副本?我在谷歌搜索,但我什么都没发现.

请帮我.

解决方法 Here’s一个完整的例子似乎可以完成您想要做的大部分工作.似乎唯一需要做的更改是创建一个新的ImageVIEw并将位图复制到其中.为此,您需要将类MyDragListener的onDrag()方法更改为如下所示:

case DragEvent.ACTION_DROP:    // Dropped,reassign VIEw to VIEwGroup    VIEw vIEw = (VIEw) event.getLocalState();    //VIEwGroup owner = (VIEwGroup) vIEw.getParent(); // Removed    //owner.removeVIEw(vIEw);                         // Removed    linearLayout container = (linearLayout) v;    // Added the following to copy the old vIEw's bitmap to a new ImageVIEw:    ImageVIEw oldVIEw = (ImageVIEw) vIEw;    ImageVIEw newVIEw = new ImageVIEw(getApplicationContext());    newVIEw.setimageBitmap(((BitmapDrawable) oldVIEw.getDrawable()).getBitmap());    container.addVIEw(newVIEw);                       // Changed to add new vIEw instead    vIEw.setVisibility(VIEw.VISIBLE);    break;
总结

以上是内存溢出为你收集整理的Android – 拖放ImageView的副本全部内容,希望文章能够帮你解决Android – 拖放ImageView的副本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1130016.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存