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

  • Home
  • SEARCH
  • 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 8381117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:37:30+00:00 2026-06-09T16:37:30+00:00

I have two classes, Class A called Apply and Class B called Option I

  • 0

I have two classes, Class A called Apply and Class B called Option
I want class A to get a resource from class B, but I’m getting error

the error I’m getting

Cannot make a static reference to the non-static method getResources() from the type ContextWrapper

the function on class A

public static void applyBitmap(int resourceID) {
    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inScaled = true;
    opt.inPurgeable = true;
    opt.inInputShareable = true;
    Bitmap brightBitmap = BitmapFactory.decodeResource(getResources(), resourceID, opt);
    brightBitmap = Bitmap.createScaledBitmap(brightBitmap, 100, 100, false);
    MyBitmap = brightBitmap;

}

and example of a resource button in class B

    // the 34th button
    Button tf = (Button) findViewById(R.id.tFour);
    tf.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Apply.applyBitmap(R.drawable.tFour);

        }
    });

note*: before when the function was on class B in was working great, but know I think I need to static the resource but how ? I don’t know

I tried Option.getResources() but it didn’t work, it gives an error

  • 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-09T16:37:31+00:00Added an answer on June 9, 2026 at 4:37 pm

    You are accessing getResources() without a reference to a Context. Because this is a static method, you can only access other static methods within that class without providing a reference.

    Instead, you must pass the Context as an argument:

    // the 34th button
    Button tf = (Button) findViewById(R.id.tFour);
    tf.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Apply.applyBitmap(v.getContext(), R.drawable.tFour); // Pass your context to the static method
        }
    });
    

    Then, you must reference it for getResources():

    public static void applyBitmap(Context context, int resourceID) {
        BitmapFactory.Options opt = new BitmapFactory.Options();
        opt.inScaled = true;
        opt.inPurgeable = true;
        opt.inInputShareable = true;
        Bitmap brightBitmap = BitmapFactory.decodeResource(context.getResources(), resourceID, opt); // Use the passed context to access resources
        brightBitmap = Bitmap.createScaledBitmap(brightBitmap, 100, 100, false);
        MyBitmap = brightBitmap;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bas class called Media with two classes that inherit from it,
I have two classes; my Main class and a class called BlockPlace. I want
If I have a class called A and I have two classes that derive
I have two classes class A { public string something { get; set; }
I have two classes: public class MultilingualString { public int Id { get; set;
I have a two classes, a controller called AppController and a class called URLDelegate
I have two test classes called TT_Common and TT_Container which extends CPPUNIT_NS::TestFixture: class TT_Common
I have two classes, derived from a common class. The common class has a
So I have two classes. One is a class called Main. The Main class
For simplicity let's say I have two classes: a class called Car and a

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.