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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:57:42+00:00 2026-05-30T02:57:42+00:00

I am using this following code but it don’t seem to work properly I

  • 0

I am using this following code but it don’t seem to work properly
I am trying to add an image using a button and then showing thumbnail in a specific relativeLayout

  public void showViewOfReceiptFromSelecting(String uriString)
     {
         byte[] imageData = null;
         try
         {
         InputStream fis = this.getContentResolver().openInputStream(Uri.parse((uriString)));
         Bitmap imageBitmap = BitmapFactory.decodeStream(fis);
         imageBitmap = Bitmap.createScaledBitmap(imageBitmap, 40, 40, false);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
         imageData = baos.toByteArray();
         ImageView image = new ImageView(this); 
         image.setImageBitmap(imageBitmap);
         image.setId(counterOfReceipts);
         RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
         rlp.addRule(RelativeLayout.RIGHT_OF, counterOfReceipts - 1);
         myRelalativelayout.addView(image, rlp);  // a relative Layout i already defined earlier in the code
         counterOfReceipts = counterOfReceipts + 1 ;
         }
         catch(IOException e) {
            e.printStackTrace();
         } 
     }

Now the problem is, whenever i try to add one more thumbnail, it replaces the old one. Please tell me what to do …

Best Regards

  • 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-30T02:57:44+00:00Added an answer on May 30, 2026 at 2:57 am

    Of course it gets replaced, because you’re not adding a new view to the layout, just replacing the image in it.
    Try replacing the RelativeLayout with a LinearLayout, then whenever you want to add a new thumbnail, create a new ImageView, set that ImageView’s background to your bitmap, then add it to the LinearLayout.

    Don’t forget to define your LinearLayout orientation.

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

Sidebar

Related Questions

I'm using following code but cannot return data from MySQL. This is the output:
i'm trying to duplicate a swf loaded using greensocks LoaderMax but i don't seem
I have the following code snippet: using (SPSite site = new SPSite(this.ListAddress)) { using
I am using 'git' to checkout chromium code by following this document: http://code.google.com/p/chromium/wiki/UsingGit And
I'm using the following code to update a DataGridView's cell value. This is called
I'm using the following code.. $(document).ready(function(){ $(#test a).click(function(){ var labelTo = $(this).text(); window.location =
This is using the web app framework, not Django. The following template code is
I'm attempting to translate the following C# code into IronPython but I don't know
I'm using the following code to get the image filenames from an HTML file.
I try to get this following url using the downloadURL function as follows: http://www.ncbi.nlm.nih.gov/nuccore/27884304

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.