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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:49:44+00:00 2026-06-13T15:49:44+00:00

I checked the solution here: Adding multiple views of the same type Its given

  • 0

I checked the solution here:

Adding multiple views of the same type

Its given that, create a new View everytime you add it instead of changing only 1 view.

But i am doing this:

for (int i = 0; i < 10; i++) {

LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(
                    CommentsActivity.LAYOUT_INFLATER_SERVICE);
View cv = vi.inflate(R.layout.item, null);

TextView textView1 = (TextView) cv.findViewById(R.id.tv1);
textView1.setText("-" + i);
TextView textView2 = (TextView) cv.findViewById(R.id.tv2);
textView2.setText("--" + i);
LinearLayout insertPoint = (LinearLayout) findViewById(R.id.layout);
insertPoint.addView(cv, 0, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
}

so its like creating a new inflater and view for every i. But i am only getting the last item.

ie.., only 1 inflatedView with tv1 as -9 and tv2 as –9

seems like everytime i go into the for loop, the old view is being replaced by the new view. How to add all the 10 views??

ThankYou

  • 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-13T15:49:46+00:00Added an answer on June 13, 2026 at 3:49 pm

    usually I use this

    private void renewDetail(){
            llDetail.removeAllViews();
            for (int i = 0; i < 10; i++) {
                llDetail.addView(new ChildDetailNotePieDiagram(context, "Name", 1000, 10));
            }
        }
    

    the logic is first I clear all view from the parent layout and then add view to the parent layout.

    where llDetail is a linear layout and I create a linear layout class ChildDetailNotePieDiagram and add it to the linear layout so basically it’s a different solution from what you use now
    but I think you can try my solution if you want 🙂
    feel free to ask any question about this in the comment

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

Sidebar

Related Questions

After some use Visual Studio 2008 when opening a solution that is checked into
I have checked for a solution here but cannot seem to find one. I
I have checked all posts here, but can't find a solution for me so
I have a solution checked into TFS. Looking in the source control explorer I
I added a project to a solution checked into a team foundation server solution
I have checked other questions here at SO, however they do not answer my
I saw similar questions here, but I couldn't find solution to my problem. I
Here I construct an array: var optionTexts = []; $('#stripeMeSubSubCat tr').each(function(){ if ($(this).find('input:checkbox.subsubcat_chkclass:not(:checked)').length ==
Git newbie here. Is there a way to synchronize two repositories, so that the
I checked in a changeset adding ~10 media files to my TFS branch. However,

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.