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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:39:04+00:00 2026-05-27T10:39:04+00:00

I am trying to put some views into a Fragment using a LayoutInflater. They

  • 0

I am trying to put some views into a Fragment using a LayoutInflater. They are TextViews, but I only seem to be able to set the values on the first ones I add. It looks like an id clash is causing the problem, but I am at a loss as to how to get over this.
The relevant bit of my onCreateView looks like this:

    ViewGroup vg = (ViewGroup) inflater.inflate(R.layout.data_viewer,
            container, false);

    HashMap<String, Long> titles = mHelper.getTitles("firestations");

    for (String key : titles.keySet()) {
        **View row = inflater.inflate(R.layout.row, vg, true);
        TextView label = (TextView) row.findViewById(R.id.textView1);
        label.setText(key);**
        TextView value = (TextView) row.findViewById(R.id.textView2);
        value.setText(getArg(key));
    }

As you can see from the starred lines I am inflating a ‘row’ (this is just a horizontal linear layout with 2 text views called textView1 and textView2 in it). I supply the handle of the ViewGroup that I inflated and pass true to get the views attached to the parent. All of this seems to work fine. Then I call findViewById on the row that I have just inflated. I would have thought that this find would only pick up the children of that specific row. It looks like the find is using a wider scope and is matching the full set of ids (which are the same – they are all from the same piece of xml). It is then giving me back the first one.
The result of all this is that I am getting the screen correctly laid out with the last row of data displayed on the top pair of TextViews. The rest of the TextViews have their xml defined default text in them.

Anyone know how I can get around this?

Thanks,

Anthony Nolan

  • 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-27T10:39:05+00:00Added an answer on May 27, 2026 at 10:39 am

    Looks like there might be a minor bug in the support code. Adding the views explicitly (instead of using the true param) works fine:

        for (String key : titles.keySet()) {
            View row = inflater.inflate(R.layout.row, vg, false);
            TextView label = (TextView) row.findViewById(R.id.textView1);
            label.setText(key);
            TextView value = (TextView) row.findViewById(R.id.textView2);
            value.setText(getArg(key));
            vg.addView(row);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to put some distributed caching into play, I'm using this indeXus.Net
I'm trying to put some sites i crawled into a shelve, but the shelve
I am trying to DRY up some code in HAML, but seem to have
I'm trying to put some folders on my hard-drive into an array. For instance,
I'm trying to put some specs around a new rails 3 project I am
I'm trying to write a small wsgi application which will put some objects to
I am trying to create a 5x5 grid with 2 exits and put some
I'm trying to generate some code at runtime where I put in some boiler-plate
In the code below I'm trying to load some images and put them in
I am trying to right-align the output of some PL/SQL code, but dbms_output.put_line is

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.