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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:53:22+00:00 2026-06-16T04:53:22+00:00

I am having a problem with a custom view I am currently doing for

  • 0

I am having a problem with a custom view I am currently doing for an app on android, I know there are many questions related with inflaters, but I cannot get around this problem.

the inflater i working just fine, but it should be doing the loop 3 times and is only doing it 1 so I only get one view on my final layout.

the relevant part of the code is this one

 void populate(String strcline, String url){
lLfD = (LinearLayout)findViewById(R.id.lLfD);

    try{

    JSONArray a1 = new JSONArray(strcline);

    for(int i = 0; i < a1.length(); i++){

        JSONArray a2 =  a1.getJSONArray(i);

        final String fUserId = a2.getString(0);
        String userName = a2.getString(1);
        String userPicture = url + a2.getString(2);


        View child = getLayoutInflater().inflate(R.layout.cellevery, lLfD);
        ImageView avatar = (ImageView)findViewById(R.id.cellAvatar);
        downloadFile(userPicture, avatar);
        TextView cellName = (TextView)findViewById(R.id.cellName);
        cellName.setText(userName);


        lLfD.addView(child);

    }
    }catch(Exception e){

    }
    pDialog.dismiss();

}

  • 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-16T04:53:24+00:00Added an answer on June 16, 2026 at 4:53 am

    You look like you need to run findViewById only on the inflated view, otherwise it will just find the first one which is only the first one in your loop:

       View child = getLayoutInflater().inflate(R.layout.cellevery, lLfD);
        ImageView avatar = (ImageView)child.findViewById(R.id.cellAvatar);
        downloadFile(userPicture, avatar);
        TextView cellName = (TextView)child.findViewById(R.id.cellName);
        cellName.setText(userName);
    

    Here’s an explanation of findViewById in your loop:

    Loop 1:
    1LfD->child1->R.id.cellAvatar (findViewById(R.id.cellAvatar) finds this one)
    
    Loop 2:
    
    1Lfd->
       child1->R.id.cellAvatar
       child2->R.id.cellAvatar (findViewById(R.id.cellAvatar) finds the child1.cellAvatar again)
    
    Loop 3:
    1LfD->
       child1->R.id.cellAvatar 
       child2->R.id.cellAvatar 
       child3->R.id.cellAvatar (findViewById(R.id.cellAvatar) finds the child1.cellAvatar again)
    

    by using child.findViewById(R.id.cellAvatar), it ensures that you find the correct R.id.cellAvatar for each run of the loop.

    Does that make sense?

    Update 2:

    When you call:

    getLayoutInflater().inflate(R.layout.cellevery, lLfD);
    

    You are already setting the parent view as the second argument so you don’t need to call:

    lLfD.addView(child);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I´m having a problem with my Android Project. I have a screen filling custom
I am having problem with previewing custom performance counters with PerflibV2. Performance Monitor shows
I am having a problem with filling a ShapeDrawable containing a custom PathShape using
I'm having problem with datagrid view. I have attached an image with the code
In the iPhone app I'm currently working on, I'd like two view controllers (I'll
I'm having a problem. I have a Custom UITableViewCel, the cell contains a slider
Hi there I am having a problem with my form validation, basically the problem
I'm having a problem with an android activity that extends ListActivity . It seems
I'm having a problem with a custom NSPopUpButtonCell in a table that's instantiated when
I'm having an issue using the canvas.drawText() method. I have a custom view, as

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.