Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8023407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:33:20+00:00 2026-06-04T22:33:20+00:00

I need to know which image is in which cell, so I have only

  • 0

I need to know which image is in which cell, so I have only tried using .setId() and .getId(). But if there’s any other way to do this, just let me know.

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 Id is the correct one, like, if (Id == 1) open... else if (id == 2) open other thing. But I can’t get the Id to be saved to the image (or saved to that ImageCell).

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.

I’m using a Toast to show the image dropped Id. This is the ImageCell 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);
}

DragActivity.m is just a variable that’s used to change the picture.

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);
}

Anyone know what I’m doing wrong? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:33:22+00:00Added an answer on June 4, 2026 at 10:33 pm

    I think you are trying to swap images in that case you can identify ImageView uniquely by tag like this:

    ImageView imageView = new ImageView(_context);
    imageView.setTag(1);
    

    And then on GridView‘s / ImageView‘s click check its tag like this:

    gridview.setOnItemClickListener(new OnItemClickListener() {
    
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
    
            Tag = (Integer) arg1.getTag();
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to know which views does a user have which privileges on. I'm
I have a situation where I need to know which features are to be
I need to know how to rotate an image, which is in yuv420p format
Is there any way to know which verion of Windows we are working on?
I have a some code that changes the background image of a cell which
I need to know which image file type was used in the file i
Need to know which event triggered after text selection done in Apple iPad. It
I need to know which stored procedures are running. It's not an option to
I need to know which physical column is associated to a persistent's attribute. e.g.
I need to know which of the 3 is best for me. My requirements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.