简体   繁体   English

我想通过单击选择一个图像视图,然后通过第二次单击将复制的图像视图添加到另一个视图。

[英]I'd like to select an Image View with one click and then add a duplicated image view to another view with a second click.

For our purposes, let's think of it as a chess game.出于我们的目的,让我们将其视为一种国际象棋游戏。 So I touch the queen and click it, then I touch the square that I'd like to move the queen to and the queen moves to that square.所以我触摸皇后并点击它,然后我触摸我想要将皇后移动到的方格,然后皇后移动到那个方格。

I think this is a pretty simple task, but I've searched high and low for an answer but yet to find one.我认为这是一项非常简单的任务,但我已经四处寻找答案,但还没有找到。
Original I was using an OnTouchListener and Drag and Drop, but it will work much better with OnClick so that the user clicks twice to move the object.原来我使用的是 OnTouchListener 和拖放,但它会更好地与 OnClick 一起使用,以便用户单击两次以移动对象。 (I think) (我认为)

Thanks for the help.谢谢您的帮助。

Setup an OnClickListener and a variable to hold the selected field.设置一个 OnClickListener 和一个变量来保存所选字段。 onClick, check if there is already a field selected, if not, store the clicked field in the variable. onClick,检查是否已经有选择的字段,如果没有,将点击的字段存储在变量中。 If there is already a selected field stored, move the piece from the stored field to the clicked field and clear the variable to allow a new move.如果已经存储了一个选定的字段,将块从存储的字段移动到单击的字段并清除变量以允许新的移动。 You can apply your game logic/rules in the second branch too.您也可以在第二个分支中应用您的游戏逻辑/规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想实现一个回收器视图点击事件 - I'd like to implement a recycler view click event 避免在图像视图android中单击多次 - Avoid multi-click in image view android 旋转图像视图在点击时属于 RecyclerView - Rotating image view belongs to a RecyclerView on click 处理卡片视图的第二次点击 - Handle second click on card view 单击一个卡片视图会影响另一个卡片视图值 - Click on one card view affected another card view value 当我单击活动时,我在其中有3个文本视图。 我想2秒的差距后加载文本视图一个又一个什么样的? - When I click on the activity I have 3 Text View in that. I want to load the Text View one after another like after a gap of 2 seconds? 如何像单击鼠标一样选择树视图节点以更新属性视图 - How to select a treeview node like a click of mouse to update properties view 如何在 Android 中单击 Recycler View 并获取另一个 dataActivity 像 playstore? - How to click on Recycler View in Android and get Another dataActivity like playstore? Android:在父级上具有单击侦听器的同时将视图添加到另一个视图中 - Android: Add view into another while having a click listener on the parent 列表视图搜索不适用于单击项目。 返回原始项目位置 - List View search is not working on item click. Returns original item position
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM