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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:06:08+00:00 2026-05-27T06:06:08+00:00

I am implementing an application displaying images and messages obtained from .net server. For

  • 0

I am implementing an application displaying images and messages obtained from .net server. For that I’m adding LinearLayout‘s with TextView and ImageView dynamically by using for loop.
At first I am getting messages and I’m adding them to the TextView with dummy images placed in ImageView:

for(int i = 0; i < messages.size(); i++) { 
    FrameLayout f1 = new FrameLayout(this);
    LinearLayout l1 = new LinearLayout(this);
    LinearLayout l2 = new LinearLayout(this);
    im = new ImageView(this);
    TextView tv = new TextView(this);
    tv.setText(messages.get(i).getmessage());

    im.setImageResource(R.drawable.person);
    l1.addView(tv);
    l2.addView(im);
    f1.addView(l1);
    f1.addView(l2);

    ((LinearLayout)findViewById(R.id.LinearlayoutMessage)).addView(f1);
}

After some time I am getting original images. My intention is to replace the dummy images with original ones. To achieve this I’m using imageview.getid() unfortunately I’m getting last id of the imageview. But I need to get each individual imageview id’s.

What is the best way of changing dummy images with real ones?

  • 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-27T06:06:09+00:00Added an answer on May 27, 2026 at 6:06 am

    Looks like you need to store each imageView id in a map from each message -> imageView like so:

    Map<Message, Long> messageMapping = new HashMap<Message, Long>();
    
    for(int i = 0; i < messages.size(); i++) { 
        FrameLayout f1 = new FrameLayout(this);
        LinearLayout l1 = new LinearLayout(this);
        LinearLayout l2 = new LinearLayout(this);
        im = new ImageView(this);
        TextView tv = new TextView(this);
    
        //add mapping
        messageMapping.put(messages.get(i), im.getId());
    
        tv.setText(messages.get(i).getmessage());
    
        im.setImageResource(R.drawable.person);
        l1.addView(tv);
        l2.addView(im);
        f1.addView(l1);
        f1.addView(l2);
    
        ((LinearLayout)findViewById(R.id.LinearlayoutMessage)).addView(f1);
    }
    

    Then when it comes time to lazy load your images into the existing imageViews you simply need to look up the imageView id reference by message mapping:

    (Total guess of what your code could look like)

    for(int i = 0; i < messages.size(); i++){
        Image image = queryServerForImage(messages.get(i).getImageId());
        ImageView imageView = ((ImageView)findViewById(messageMapping.get(messages.get(i))));
        //some conversion & seteup may be needed to get image into proper format
        imageView.setImageBitmap(image);
    }
    

    You may be able to do something similar with async tasks. You could span each one in the message ImageView creation loop with the associated resource id and having each asyc task update the ui from the network response.

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

Sidebar

Related Questions

I have a WPF application which is displaying field validation messages by implementing the
I am implementing an application that launches iTunes from a 'music page'. This is
we are implementing an AIR application in Flex. We populate dynamically a canvas and
I'm implementing a distributed application, server with rails and mobile clients in objective c
I'm currently implementing a client application that POST's a file over HTTP and have
While implementing XML file reading/writing in my application I saw that when I call
For those that work with application extensibility in .NET, what do you prefer doing
I am implementing one application gust i am adding validations in login page implemented
(tl;dr: see summary at the bottom.) I am implementing an application that pulls content
I am implementing an application that uses websockets and a console accessed via Telnet.

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.