Note that there are some explanatory texts on larger screens.

plurals
  1. POSet image Id to image added using drag and drop
    primarykey
    data
    text
    <p>I need to know which image is in which cell, so I have only tried using <code>.setId()</code> and <code>.getId()</code>. But if there's any other way to do this, just let me know.</p> <p>Images are added when I click a button. I have nothing showing where they appear, but here's my problem, I'm trying to add a Id to each image that I'm able to add. So when I drop them in the GridView and click one of them I can do something else if the <code>Id</code> is the correct one, like, <code>if (Id == 1) open... else if (id == 2) open other thing</code>. But I can't get the <code>Id</code> to be saved to the image (or saved to that <code>ImageCell</code>).</p> <p>Example of the problem I'm getting: If I added image1 which have Id1 and then add image2 which have Id2 the image1 Id will change to the last image added (in this case image2 Id). I have tried a lot of different ways of setting the Id, but I'm still getting the last image id in the first one dropped.</p> <p>I'm using a Toast to show the image dropped Id. This is the ImageCell code.</p> <pre><code>public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo) { mEmpty = false; ImageView sourceView = (ImageView) source; sourceView.setId(DragActivity.m); Drawable d = sourceView.getDrawable (); this.setId(sourceView.getId()); if (d != null) { this.setImageDrawable (d); this.setId(sourceView.getId()); prueba = this.getId(); } toast ("" + prueba); } </code></pre> <p>DragActivity.m is just a variable that's used to change the picture.</p> <pre><code>public void addNewImageToScreen() { int resourceId = R.drawable.hello; m = mImageCount % 3; if (m == 1) { resourceId = R.drawable.photo1; } else if (m == 2) { resourceId = R.drawable.photo2; } addNewImageToScreen(resourceId); } </code></pre> <p>Anyone know what I'm doing wrong? Thanks</p>
    singulars
    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