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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:15:27+00:00 2026-05-20T01:15:27+00:00

I’m trying to put different images (.jpg , .png) dynamically into a ListView from

  • 0

I’m trying to put different images (.jpg , .png) dynamically into a ListView from res/drawable .
The names from the images I get from a database.
The images themselves are in the res/drawable folder.

This is what I already have, With an error of 😀

String imgName; –> There are the img names I need from the database

Drawable drawable;    
    drawable = Class.appContext.getResources().getDrawable(Class.appContext.getResources().getIdentifier("com.example.test:drawable/"+imgName,null,null));  

Then I get this into a ArrayList for every image in the database(+- 200 images):

ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> map = new HashMap<String, Object>();

map = new HashMap<String, Object>();
map.put("img",drawable);

          map.put("text", "some text");
          list.add(map);

Now I RETURN list;

In the Class where I call :

listReceive = Class.getImages(appContext); 

listSetup = new SimpleAdapter(this, listReceive, R.layout.row,
                        new String[] {"img", "text"}, new int[] {R.id.IMG_CELL, R.id.TEXT_CELL});
                lvList.setAdapter(listSetup);

XML row is an ImageView and a TextView.

System.out :resolveUri failed on bad
bitmap uri:
android.drawable.bitmapDrawable@405739
resolveUri failed on bad bitmap uri:
android.drawable.bitmapDrawable@405639
resolveUri failed on bad bitmap uri:
android.drawable.bitmapDrawable@405959
resolveUri failed on bad bitmap uri:
android.drawable.bitmapDrawable@405677…
… …

I got it working when I saved images into local or SDcard memory, and then put the path inside the arraylist like:

map.put("img","/data/data/com.example.test/images/" + imgName);

I can’t use this because then i will need to copy the pictures from res/drawable onto local or SD.This takes up 2 times the memory. can’t have that of.

There must be a way to get images dynamically from the drawable.

Any one knows what I’m missing here?
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-05-20T01:15:27+00:00Added an answer on May 20, 2026 at 1:15 am

    The SimpleAdapter expects an integer or string that specifies a resource or image URI:

    public void setViewImage (ImageView v, String value)
    Since: API Level 1
    

    Called by bindView() to set the image for an ImageView but only if there is no existing ViewBinder or if the existing ViewBinder cannot handle binding to an ImageView. By default, the value will be treated as an image resource. If the value cannot be used as an image resource, the value is used as an image Uri. This method is called instead of setViewImage(ImageView, int) if the supplied data is not an int or Integer.

    I believe should use setViewBinder to provide a ViewBinder for the SimpleAdapter to handle binding the Drawable data to the ImageView. Basically, the setViewValue() method should return false unless it is called for your image view. When it is called for your image view, the method should set the data in the view and return true. The return value indicates whether the ViewBinder was able to set the view or whether the adapter should try to bind the data itself via its default behavior.

    Maybe something like:

    private final SimpleAdapter.ViewBinder mViewBinder =
        new SimpleAdapter.ViewBinder() {
            @Override
            public boolean setViewValue(
                    final View view,
                    final Object data,
                    final String textRepresentation) {
    
                if (view instanceof ImageView) {
                    ((ImageView) view).setImageDrawable((Drawable) data);
                    return true;
                }
    
                return false;
            }
        };
    
    ...
    
    listSetup .setViewBinder(mViewBinder);
    

    I’ve done a similar thing with a SimpleCursorAdapter and its ViewBinder.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to loop through a bunch of documents I have to put
I am currently running into a problem where an element is coming back from
I am using jsonparser to parse data and images obtained from json response. When
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.