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 8029055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:19:22+00:00 2026-06-05T00:19:22+00:00

I have 16 imageview, each set to onBtnClick as a listner, inside this method

  • 0

I have 16 imageview, each set to onBtnClick as a listner, inside this method it checks whether the imageview id corresponds to a specific id, I need to change this so it checks the image resource inside the imageview, e.g.

public void onBtnClicked(View v)
{

  if( v.getId() == R.id.img1 )
  {
      Intent guess = new Intent(this, com.Logo_Master.Guesslogo.class);
      guess.putExtra("image","img1");
      startActivity(guess);
  }
}

needs to be something like:

public void onBtnClicked(View v)
{

  if( v.getId() == R.drawable.img1 )
  {
      Intent guess = new Intent(this, com.Logo_Master.Guesslogo.class);
      guess.putExtra("image","img1");
      startActivity(guess);
  }
}

or something similar…..so it checks the image inside the imageview rather than the imageview……

Thank you.

/EDIT/

Random random = new Random( System.currentTimeMillis() );
    List<Integer> generated = new ArrayList<Integer>();
    for (int i = 0; i < imageViews.length; i++) {

        int v = imageViews[i];
        int next = random.nextInt( 16 );
        if ( !generated.contains( next ) ) {
            generated.add( next );
            ImageView iv = (ImageView) findViewById( v );
            iv.setImageResource( images[next] );
            Object tag = (Object) new Integer(getImageName(this, String.valueOf(images[next])));
            iv.setTag(tag);
        }
        else {
            i--;
        }
    }

public static int getImageId(Context context, String imageName) {
return context.getResources().getIdentifier("id/" + imageName + "guess", null, context.getPackageName());
}


public static int getImageName(Context context, String imageName) 
{
return context.getResources().getIdentifier("drawable/" + imageName + "guess", null,     context.getPackageName());
}
  • 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-05T00:19:26+00:00Added an answer on June 5, 2026 at 12:19 am

    You can use tags to achieve this:

    When creating your ImageView (in code or in XML), define a tag:

    android:tag = "tag"
    

    OR

    Object tag = (Object) new Integer(R.drawable.img1);
    imageView.setTag(tag);
    

    Then retrieve the tag before you need it by:

    Object tag = imageView.getTag();
    int drawableId = Integer.parseInt(tag.toString());
    if( drawableId == R.drawable.img1 ) {
          ....
    }
    

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView composed of LinearLayouts. Inside each is an ImageView, TextView and
I have imageView in activity. How I can set position this imageView in my
I have imageView inside a relative layout. And when i create the activity i
I have a 4x1 widget that holds several ImageView views inside a LinearLayout .
I have an imageview in which I want an image to be set. My
If i have an ImageView that fills the screen. The ImageView background is set
I have a TableLayout with 3 TableRows, each TableRow has 3 ImageViews. Each ImageView
I have imageView with some frame imageView.frame = CGRectMake(0,0, 100, 100); imageView.contentMode = UIViewContentModeScaleAspectFit;
In my view i have ImageView.If i click ,it should open nextview. Please help
I have a ImageView and draw some things on that view. Now I want

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.