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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:52:38+00:00 2026-05-27T21:52:38+00:00

I currently have a simple list view adapter that holds two rows of text.

  • 0

I currently have a simple list view adapter that holds two rows of text. What I am trying to do next is add the option of displaying a photo that the user took in the list view. I modified my list adapter like so:

standardAdapter = new SimpleAdapter(this, list, R.layout.post_layout,
                new String[] { "time", "post", "image"}, new int[] {
                        R.id.postTimeTextView, R.id.postTextView, R.id.post_imageView});

Then I add it to the hash map as usual and refresh the adapter:

// create a new hash map with the text from the post
        feedPostMap = new HashMap<String, Object>();
        feedPostMap.put("time", currentTimePost);
        feedPostMap.put("post", post);
        if(photoWasTaken == 1){
            feedPostMap.put("image", pictureTaken);
        }
        //add map to list
        list.add(feedPostMap);

        // refresh the adapter
        standardAdapter.notifyDataSetChanged();

Lastly, here is the code for activity on result:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Log.d(TAG, "ON activity for result- CAMERA");
        if (resultCode == Activity.RESULT_OK) {
            //get and decode the file
            pictureTaken = BitmapFactory.decodeFile("/sdcard/livefeedrTemp.png");

            //Display picture above the text box
            imageViewShowPictureTaken.setImageBitmap(pictureTaken);
            displayPhotoLayout.setVisibility(LinearLayout.VISIBLE);

            //NEW - make photo variable = 1
            photoWasTaken = 1;
        }
    }

However I am running into an issue. The photo, in bitmap form, is not being added to the list view. It just appears as empty white space. Am I doing something wrong here? Secondly, if the user decided not to take a picture, then the image view should not be displayed. I’m not sure how to implement this. Should I create a custom list adapter?

Thanks for your help

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

    The problem is that SimpleAdapter don’t support Bitmaps by default.

    By default, the value will be treated as an image resource. If the
    value cannot be used as an image resource, the value is used as an
    image Uri.

    There is a solution, however. You can set a custom ViewBinder and make the binding by yourself.

    class MyViewBinder implements SimpleAdapter.ViewBinder {
        @Override
        public boolean setViewValue(View view, Object data, String textRepresentation) {
            if (view instanceof ImageView && data instanceof Bitmap) {
                ImageView v = (ImageView)view;
                v.setImageBitmap((Bitmap)data);
                // return true to signal that bind was successful
                return true;
            }
            return false;
        }
    }
    

    And set this to your SimpleAdapter:

    adapter.setViewBinder(new MyViewBinder());

    This way every time the SimpleAdapter tries to bind a value to a View it first calles your View binder’s setViewValue method. If it returns false, it tries to bind it itself.


    You can also try to put into your map an URL as a string pointing to the sd card location. I’m not sure however, that the SimpleAdapter can handle this.


    Also see this post:
    Dynamically show images from resource/drawable

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

Sidebar

Related Questions

Ok, currently I have a view in my android app that displays a list
So I have a view that does a queryset and returns a simple list:
I currently have a simple form that when you click the save button will
Currently I have a simple maven project that is building a jar file and
I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
On my index/list view I have a list of records from the database, currently
I currently have a custom listview where each item on the list contains two
Currently I have a simple setup where I maintain a list of bools corresponding
Currently I have a simple knockoutJS object, with a few observables. But this object
I have a simple ticket logging application build on LAMP. I am currently playing

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.