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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:28:55+00:00 2026-05-28T21:28:55+00:00

First time I post a question, so here it goes. I want to push

  • 0

First time I post a question, so here it goes.
I want to push on a button, so it opens the gallery, pick a picture, then shows it somewhere on the screen (layout).

I got this far by now:

public void FotoKiezen(View v) {
    Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
    photoPickerIntent.setType("image/*");
    startActivityForResult(photoPickerIntent, 1);
}

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case 1:
     {
      if (resultCode == RESULT_OK)
      {
        Uri photoUri = data.getData();
        if (photoUri != null)
        {
        try {
              String[] filePathColumn = {MediaStore.Images.Media.DATA};
              Cursor cursor = getContentResolver().query(photoUri, filePathColumn, null, null, null); 
         cursor.moveToFirst();
     int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
     String filePath = cursor.getString(columnIndex);
     cursor.close();
     Bitmap bMap = BitmapFactory.decodeFile(filePath);
     ImageView.setImageBitmap(bMap);


     }catch(Exception e)
      {}
      }
    }// resultCode
    }// case 1
    }// switch, request code
}// public void onActivityResult

There is some other code above it too, but here somewhere is the problem.

I get an error on the line ImageView.setImageBitmap(bMap);
The error:

Cannot make a static reference to the non-static method setImageBitmap(Bitmap) from the type ImageView

I searched a lot on the internet, and tried many things, but I can’t resolve it.
Maybe it is really easy and I just don’t see it.

I am beginner at Java android programming, used to program in C++.
So also some explanation about the error would be very nice 😀

  • 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-28T21:28:55+00:00Added an answer on May 28, 2026 at 9:28 pm

    You must create the object of ImageView class? For example:

    ImageView img = new ImageView(this);
    img.setImageBitmap(bMap);
    

    or

    ImageView img = (ImageView)findViewById(R.id.<your image view id>);
    img.setImageBitmap(bMap);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time here so I hope I post this question at
This is my first post to this website. Here is my question: I want
this is my first time to post a question here, I will try to
Here goes my first question. First of all I'm new with Java and still
First time asking a question here. Usually I can find my answer without having
My first question so here it goes. My goal is to have a simple
I'm not entirely sure how to post this question, but here goes... I have
This is my first post in here and I wouldn't post a question here
This is my first time posting a question here, it has been a valuable
This is my first question here, and the first time I haven't been able

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.