在表格布局中交换图像
我有一个 ImageView 的 2D 数组,目前正在 tableLayout 中显示它们中的每一个。如果我想切换 ImageView,我认为我需要交换每个 [i][j] imageView 分配到的位图。例如,如果我想交换 [0][0] 和 [0][1] 处的图像位置,我该怎么做?
我有一种感觉,我需要将每个底层位图重新分配给适当的图像视图。
I have a 2D array of ImageViews and am currently displaying each of them in a tableLayout. If I wanted to switch the ImageViews, I think that I need to swap the bitmaps that each [i][j] imageViews are assigned to. For example, if I wanted to swap positions of the images at [0][0] and [0][1], how would I do this?
I have a feeling that I would need to reassign each underlying bitmap to the appropriate imageview.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试在图像视图上获取可绘制对象并将其保存到变量中:
然后通过以下方式交换可绘制对象:
我认为这将切换视图的图像,或者您实际上需要移动图像视图的位置吗?
You could try getting the Drawable, on the imageviews and save it to variables:
Then you swap the drawables by:
I think that will switch the images of the views, or do you actually need to move the positions of the imageviews?