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

  • Home
  • SEARCH
  • 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 4046910
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:37:27+00:00 2026-05-20T13:37:27+00:00

I am building something like a ListView, but I’m rolling my own because I

  • 0

I am building something like a ListView, but I’m rolling my own because I want to do some custom stuff and have more control than using ArrayAdapters.

So I’ve defined part of my layout in XML, including one LinerLayout inside a ScrollView. My goal is to bind to that Linearlayout in code, then insert additional RelativeLayouts inside the LinearLayout using no XML, just code.

Here is my XML:

            <ScrollView
               xmlns:android="http://schemas.android.com/apk/res/android"
               android:id="@+id/ListScroll"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
             >

                    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                       android:layout_width="fill_parent"
                       android:id="@+id/ListHolder"
                       android:layout_height="400px"
                       android:background="#323232"
                     >
                     <!--Here is where I want the RelativeLayouts to go...  -->     
                    </LinearLayout>
            </ScrollView>

Then in code, I’m trying to add RelativeLayouts, each 50px in height, to the LinearLayout, the one above that has a height of 400px.

                //The parent container - is defined above in XML.
                itemContainer = new LinearLayout(context);
                itemContainer = (LinearLayout)findViewById(R.id.ListHolder);
                Layouts = new ArrayList<RelativeLayout>();
                Layouts = LoadWithRelativeLayouts();

                for(RelativeLayout listItem: Layouts){  

                        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, 40);
                        listItem.setLayoutParams(params);
                        itemContainer.addView(listItem);
                  }

Each one of the layouts in the array has a text view in it that says “Test”. When I step through the code, there are 10 elements in the array, and all of the textviews are there, so I would expect to see the 400px LinearLayout filled with 10 Relative layouts one after another, each with 50px height (and fill_parent width) reading “Test” – but all I see is one, as if only one got added, or they are all positioned on top of one another.

Getting screenshot now…

  • 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-20T13:37:28+00:00Added an answer on May 20, 2026 at 1:37 pm

    When you add something to a layout, you have to use layout params of that kind. So as you’re adding to a LinearLayout, you should use LinearLayout.LayoutParams.

    Then you’ll probably also need to set your LinearLayout orientation to vertical, because right now the items you don’t see are all in a row offscreen at the right 🙂

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

Sidebar

Related Questions

I'm building a simple project something like Twitter but very simple :) There are
I know I can use something like MessageBox.Show(some error) but I'm talking about an
I'd like to start messing around programming and building something with an Arduino board,
I'm building something ONLY for Chrome. I want to open several tabs with window.open
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
Building on Tony's answer on this question : If I want to do something
I currently have a db structure that looks something like what i have below
I'm building something like Facebooks Wall inside of Rails. It will look something like
I'm building something which has a countdown to a certain date/time. I have it
I am building something for mobile and would like somehow to clear, null objects,

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.