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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:42:43+00:00 2026-06-07T23:42:43+00:00

I created a static function like this. public static Bitmap Bitmap(String path) { Bitmap

  • 0

I created a static function like this.

public static Bitmap Bitmap(String path) {
    Bitmap bitmap = Bitmap
            .getBitmapResource(Display.getWidth() + "/" + path);
    System.out.println(Display.getWidth() + "" + path);
    return bitmap;
}

However, when I called like this,

private Bitmap download = Config_GlobalFunction.Bitmap("btn_download.png");

The output gave me FRIDG could not find 320/btn_download.png.

In my res folder, I got an folder which was img and inside img got 6 different folders which were 160, 240, 320, 360, 480 and 640 folder.

How can I call correct folder’s image based on Display.getWidth()?

  • 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-07T23:42:44+00:00Added an answer on June 7, 2026 at 11:42 pm

    It is possible to have a folder hierarchy under the /res folder but you must use getClass().getResourceAsStream(path) rather than Bitmap.getBitmapResource() in order to create your resource.

    This example creates a Bitmap from the path /res/img/hi_res/ui/action_arrow.png:

    String imagePath = "/img/hi_res/ui/action_arrow.png"; 
    InputStream is = getClass().getResourceAsStream(imagePath);
    byte[] imageBytes = IOUtilities.streamToBytes(is);
    Bitmap b = Bitmap.createBitmapFromBytes(imageBytes, 0, imageBytes.length, 1);
    

    It’s a bit more work but it does mean you can have a nice folder structure, rather than hundreds of images lumped together in a single folder.

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

Sidebar

Related Questions

I created hotkeys in my application using RegisterHotkey function, like this [DllImport(user32.dll)] public static
I have a function like this public static string GetNumberOfColumns(string ConnectionString) { StringBuilder sb
I've created a iPhone static library project with two targets like this Project -->
I have a method like this public static DataSet GetAllDataBaseNames() { //Instance of connection
I created a class called MyClass somewhat like this: public class MyClass { public
I have created a static library following this link . But I am facing
I have created a public static class utils.cs I want to use it in
I created a Timer private static AutoResetEvent autoEvent; private static Timer stateTimer; public static
I have a file named common.cs which contains commonly used functions like this public
I have some classes extended this way: class Baseresidence extends CActiveRecord { public static

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.