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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:25:51+00:00 2026-06-07T01:25:51+00:00

I want to change the image resource for bitmap dynamically. But I can’t call

  • 0

I want to change the image resource for bitmap dynamically. But I can’t call them with name from the drawable class.

bmp = BitmapFactory.decodeResource(getResources(), R.drawable.getImage(foldername + "/" + imagename));

I need to do something like that but I couldn’t find the proper way of doing this.,

EDITED

I think I should be more clear. I store my images under the drawable folder and they are separeted into other folders.

For example;

drawable/imageset1, drawable/imageset2,

and I want to change the Image resource for bitmap depending on user input.

For example:
User selects imageset5 from first spinner, and selects image5.png from another spinner.

  • 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-07T01:25:53+00:00Added an answer on June 7, 2026 at 1:25 am

    I hope this will do what you want

    BitmapFactory.decodeResource(getResources(), getResources().getIdentifier(foldername + "/" + imagename , "drawable", getPackageName());
    

    EDITED:

    while the above code will work only if you follow android rule which doesn’t allow sub directories in drawable folder so the above code will work only when directly accessing images from drawable.

    BitmapFactory.decodeResource(getResources(), getResources().getIdentifier( imagename , "drawable", getPackageName());
    

    As these links describe

    How to access res/drawable/"folder"

    Can the Android drawable directory contain subdirectories?

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

Sidebar

Related Questions

I want to make a fourier-transformation of an image. But how can I change
Basically, I want to render an image (bitmap) on an ImageView, but change its
I want to change an image on a view, from a popup dialog of
I have problem with dynamically created image (JavaScript). I want to change the innerHTML
When you load a bitmap from the resources like so: iv.setImageResource(R.drawable.image); if the bitmap
I have a Blackberry project in which I want to change normal image to
I want to change the sprite image. Say for example: mainSprite=[Sprite spriteWithFile:@redFile.png]; [self addChild:mainSprite];
i have many div's with the same background image and i want change this
Possible Duplicate: Android - how to set the wallpaper image I want to change
I am looking at getting the image name from an image with a src

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.