Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <ol> <li>How to determine that empty grid placeholder in the gridview?</li> </ol> </blockquote> <p>You don't really need to determine that position, you could simply monitor that position. For example your adapter could have a <code>int</code> field representing the position of the empty cell. Initially this field will be <code>8</code>(I'm assuming that the last cell of the <code>GridView</code> is the empty one at start). Whenever there is a change in the position of the empty cell(due to a drag for example) update that <code>int</code> field with the new position. When you need to know the empty cell position just have a look at that int field.</p> <blockquote> <ol> <li>How to place the touched grid in the empty grid placeholder?</li> </ol> </blockquote> <p>I assume you want to do this when the user drags the touched view on the empty cell. As you start the drag the views will receive <code>DragEvents</code>(for which I see that you set a <code>OnDragListener</code>). Knowing the empty cell position(and accordingly its view in the <code>GridView</code>) you could monitor the empty cell's view for a <code>DragEvent</code> with an action of <code>ACTION_DROP</code>. When that happens swap the data of the dragged view with the empty cell data and call <code>notifyDataSetChanged()</code>. </p> <p>Also, keep in mind that your adapter currently doesn't have an empty cell as you have 8 numbers(probably not the best choice as you need to represent an empty cell somehow) in the array that backs it. You need to have 9 values so we have room to swap the empty cell.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload