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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:10:23+00:00 2026-05-30T18:10:23+00:00

I’ve tried answers from other similar stackoverflow questions, but cannot figure out what i

  • 0

I’ve tried answers from other similar stackoverflow questions, but cannot figure out what i am doing wrong. I have an sqlite database which includes several columns, one of which is the filename of a png file stored in res/drawable. I can populate my listview with a list of items from sqlite, and on click i can display all the details stored for that chosen item – EXCEPT that the image never displays. If i simply display the name of the image file, it displays the correct name for that chosen item. But i cannot get the image itself to display.

If I hard-code the image src file into the layout xml, it displays correctly, but, i need to be able to change the image depending upon which item is selected.

Here are three ways I have tried to accomplish this (with a hard-coded name for example simplification using my res/drawable/acorn.png file). None of these works. All the rest of the correct item detail info displays, but no image. Any ideas what i am doing wrong here?

The layout xml includes:

<ImageView
android:id="@+id/wordimage"
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:maxWidth="200dp"
android:maxHeight="200dp"
android:scaleType="center"
android:contentDescription="image for this word"
/>

attempt 1:

int imageid = getResources().getIdentifier("com.brohoward.androidapps.itzadatabase:drawable/acorn.png", null, null);
ImageView imagenow = (ImageView) findViewById(R.id.wordimage);
imagenow.setImageDrawable(getResources().getDrawable(imageid));

attempt b:

int imageid = getResources().getIdentifier("com.brohoward.androidapps.itzadatabase:drawable/acorn.png", null, null);
ImageView imagenow = (ImageView) findViewById(R.id.wordimage);
imagenow.setImageResource(imageid);

attempt c:

ImageView imagenow = (ImageView) findViewById(R.id.wordimage);
imagenow.setImageBitmap(BitmapFactory.decodeFile("com.brohoward.androidapps.itzadatabase:drawable/acorn.png"));

thanks in advance!

  • 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-05-30T18:10:24+00:00Added an answer on May 30, 2026 at 6:10 pm

    Don’t include the .png in the call to getIdentifier:

    int imageid = getResources().getIdentifier("com.brohoward.androidapps.itzadatabase:drawable/acorn", null, null);
    

    Then, set the ImageView using ImageView#setImageResource:

    ImageView imagenow = (ImageView) findViewById(R.id.wordimage);
    imagenow.setImageResource(imageid);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I know there's a lot of other questions out there that deal with this
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.