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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:24:38+00:00 2026-06-17T09:24:38+00:00

( i have image in res/drawable, the name of image in database) I’ve done

  • 0

( i have image in res/drawable, the name of image in database)
I’ve done to display image from res/drawable to listview, but images appear same picture..
i want display difference image from the others….

how to change image id from drawable folder (using setImageResource()). My drawable folder contains more than 1 image and i want to change these images using name in database already stored..

here is my code from tutorial…

//the result from database (image2.jpg)

public KontakItemListBaseAdapter(Context context, ArrayList<KontakItemDetails> results) {
    itemDetailsrrayList = results;
    l_Inflater = LayoutInflater.from(context);
}

public int getCount() {
    return itemDetailsrrayList.size();
}

public Object getItem(int position) {
    return itemDetailsrrayList.get(position);
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    try{
    ViewHolder holder;
    if (convertView == null) {
        convertView = l_Inflater.inflate(R.layout.kontak_details_view, null);
        holder = new ViewHolder();
        holder.txt_itemName = (TextView) convertView.findViewById(R.id.name);
        holder.txt_itemDescription = (TextView) convertView.findViewById(R.id.itemDescription);
        holder.itemImage = (ImageView) convertView.findViewById(R.id.photo);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.txt_itemName.setText(itemDetailsrrayList.get(position).getName());
    holder.txt_itemDescription.setText(itemDetailsrrayList.get(position).getItemDescription());


    holder.itemImage.setImageResource(R.drawable.iddy);

    }catch (Exception ex) {
        throw new Error("kontakitemlistadapter :"+ex.toString());

    }
    return convertView;
}

static class ViewHolder {
    TextView txt_itemName;
    TextView txt_itemDescription;
    TextView txt_itemPrice;
    ImageView itemImage;
}

i think my problem is here..

holder.itemImage.setImageResource(R.drawable.iddy);

how to change R.drawable.iddy to be path name??

  • 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-17T09:24:39+00:00Added an answer on June 17, 2026 at 9:24 am

    you can get all Drawables id’s in an Arrays as :

    private Integer[] images;
    
    Field[] list = R.drawable.class.getFields();
    int count = 0, index = 0, j = list.length;
    
    images = new Integer[count];
    try {
       for(int i=0; i < j; i++)
        images[index++] = list[i].getInt(null);
     } catch(Exception e) {}
    

    now use images Array for setting Image src in getView method of Adapter as:

    holder.itemImage.setImageResource(images[position]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app which contain some images in res/drawable/ and shows them in
I have 10 animal images in my res/drawable folder and I want to show
I have images in res/drawable folder. I have the ID(s) of those images in
I have an app reading from an SQLite database using an Adapter to display
Before I have hardcoded the positions of Image view and name but now I
I am trying to display the profile image from a twitter list. I have
Using Eclipse IDE. The line: getClass().getResource(/res/bitmaps/image.png); returns null . I have created the res
I have a Rails app that archives high-res images (and thumbs) on S3 (via
I have the following HTML: Current HTML <div id=testContainer> <a href=testPage.htm target=_top> <img src=/res/images/testImage_M.jpg?lc=en-GB&lv=5.jpg
I have image Array with two images out of that first image its showing

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.