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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:18:57+00:00 2026-06-11T12:18:57+00:00

How can I inflate several same layouts with diffrent texts and images? I tried

  • 0

How can I inflate several same layouts with diffrent texts and images? I tried use this code

    for (final Tour t : info.tours) {
        final LinearLayout list = (LinearLayout) findViewById(R.id.tours_list);
        Log.d(Const.LOG_TAG, "Add child view to tours_list");
        final LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View child = inflater.inflate(R.layout.tour_item_for_guide_info,
                list, true);
        final ImageView tourImage = (ImageView) findViewById(R.id.tour_image);
        final String tourImgUrl = Const.HOST + t.image;
        imageLoader.DisplayImage(tourImgUrl, tourImage);
        TextView tourText = (TextView) findViewById(R.id.text);
        tourText.setText(t.name);
    }

but text and image setted in first inflated layout, replacing the previous text and image. I understand what it’s happens because layouts have same ids. Can I resolve it? I know about ListView and adapters, but I would like to learn if it might be done without them.

  • 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-11T12:18:58+00:00Added an answer on June 11, 2026 at 12:18 pm

    I assume that the ImageView and TextView – tourImage, tourText – are elements of R.layout.tour_item_for_guide_info.

    If this is so, then when you reference it, you should use the child view to get them.

    With other words, instead of:

    ImageView tourImage = (ImageView) findViewById(R.id.tour_image);
    TextView tourText = (TextView) findViewById(R.id.text);
    

    You should have:

    ImageView tourImage = (ImageView)child.findViewById(R.id.tour_image);
    TextView tourText = (TextView)child.findViewById(R.id.text);
    

    Not sure if this will definetly fix your problem, but it looks like a bug.

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

Sidebar

Related Questions

Can I inflate PreferenceScreen inside an alert dialog? This is what I've tried: final
My PUMP can (inflate) my BALLOON. No problem! But when I try to use
this is dankogai's javascript deflate http://github.com/dankogai/js-deflate I can't inflate from c#,please help me
how can an id be a parent of a layout folder? in this code,
I have this code View item = View.inflate(context, R.layout.item_layout, null); LinearLayout.LayoutParams params = new
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
I am trying to inflate an ImageView that scales a Drawable that I can
Can anybody tell me how to decompress a byte array? Here is my code.
How can I traverse through this set of data? String[] from = new String[]{AppSQLite.KEY_NAME,AppSQLite.KEY_ICON};
I want to inflate a childView of ExpandableChildView component. Code: public View getChildView(int groupPosition,

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.