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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:52:52+00:00 2026-06-13T17:52:52+00:00

i succeed in using this code in a new project, but, when copying it

  • 0

i succeed in using this code in a new project, but, when copying it in my actual code, the image displayed is not the good one
everything is well made (image is in the folder drawable, every data well declared, …)
image begin with “phoXX”, where XX is an integer (between 0 and 62)
i have an imageview (named imageView1) and a TextView (to debug, named textView1) in which i display the ID (which one is good when checking in R.java…)

here is my code :

private Context mContext;
ImageView  imageC=(ImageView)findViewById(R.id.imageView1);
TextView  Tex=(TextView)findViewById(R.id.textView1);       
Drawable drawableX = this.getResources().getDrawable(android.R.drawable.ic_dialog_alert);
Random random_monster = new Random();
int lerand = random_monster.nextInt(62);
int id = mContext.getResources().getIdentifier("drawable/pho"+lerand, "drawable",mContext.getPackageName());
if (id>0)
{
    drawableX = getResources().getDrawable(id);
}
imageC.setImageDrawable(drawableX);
Tex.setText(Integer.toString(lerand)+":"+id);

So, as i say, an image is displayed, a number is displayed, but pho29 for exemple show the image named pho48 (and pho48 doesn’t display pho29 if you ask)
ID is 2130837535, which is what appears in R.java :
public static final int pho29=0x7f02001f;
pho48 is :
public static final int pho48=0x7f020034;

for some number, the image displayed is the good one, for other, the image is not the good one (and it’s always the same image displayed for the same number….i mean for pho29, it’s ALWAYS pho48 which is displayed, in every one of my activity)

I really don’t understand what i miss…Thx all for any kind of help

Edit : below some matching (on the left side the number which should be displayed, on the right the number displayed)

2->6
17->32
19->34
24->41
43->43
51->51
36->55
37->56
38->57
56->56
59->59
61->61

As you can see, 56 is displayed by 56 AND 37….

  • 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-13T17:52:54+00:00Added an answer on June 13, 2026 at 5:52 pm

    If the same code and set of image resources work fine in one project and not in another, you should consider whether the compiled resources in the broken project are actually correct. I have found when using the automatic build feature in Eclipse that the resources don’t get recompiled when I expect them to. For instance if the last thing I did before deploying an app was to change the resources. Saving a code file change seems to drive the build system harder.

    You should try doing a clean then a rebuild. In Eclipse, on the Project menu choose “Clean…” and pick your project (or let it clean them all). Eclipse will then do a full rebuild. Or on the command line run “ant clean” followed by “ant debug”.

    Also you are using this line:

    int id = mContext.getResources().getIdentifier("drawable/pho"+lerand, "drawable",mContext.getPackageName());
    

    Here is the API spec:

    public int getIdentifier (String name, String defType, String defPackage)
    

    You don’t need to specify the type in the name field, because you are specifying it in the defType field. I don’t think it will solve your problem, but this should work at least as well:

    int id = mContext.getResources().getIdentifier("pho"+lerand, "drawable",mContext.getPackageName());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm investigating using MSMQ for my team's new project but I need to know
I am experimenting with Marshal.AllocHGlobal and found puzzling that this code would not succeed,
I know I succeed in writing my code to that address using int 13h
I tried using Exist and IN. Not only did I not succeed, it didn't
I was trying to find a solution but did not succeed even if it
I am trying to create an object of Console class, but could not succeed.
This is a question about serialization in general, but in particular I am using
I try to reload a new captcha image using a simple ajax GET. Works
I'm trying to get a contact image using its lookup URI. I succeed getting
I'm creating an actionscript project in Flex Builder. I succeed to export from Flash

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.