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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:59:39+00:00 2026-06-01T03:59:39+00:00

I’m trying to show a list of data in an android activity. Normally anyone

  • 0

I’m trying to show a list of data in an android activity. Normally anyone would do that with a simple ListView which I have used many times before. But now I’m having an application with a fixed header and footer, with the middle part (the content) scrolling underneath both the header and the footer. In the middle section I would like to add other components both above and below the list of data, but the entire part must be scrollable. I tried adding components (like a button, textview etc) to a listview but the lay-out builder in Eclipse won’t let me do that.

So I started using a ScrollView where you can easily add any component you like. But I am not allowed to add a ListView to a ScrollView, which I can understand as it would create a strange effect (as both are able to scroll).

Next I wanted to use a TableLayout to dynamically add TableRows, but on multiple websites it is said to be slow and ‘not the way to do it’. I also couldn’t find an elegant way to add the seperator between each item. With a ListView that would all be done very easily.

The following image probably explaines at best the effect I want: http://tinyurl.com/bvkec5d

The table with the ‘Table Data’ header can possibly have a lot of items and thus can become very large in length. What I don’t want is that the table has a fixed size and the items are scrollable within that table. I actually want the table to grow in size and the ScrollView containing the table should therefore be growing as well. I also want the infobox above the table to scroll along (as with any other components which might be added later).

What is the best way to achieve this effect?

  • 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-01T03:59:41+00:00Added an answer on June 1, 2026 at 3:59 am

    You can use a simple vertical LinearLayout (or a RelativeLayout) that contains your static header and footer, and use a ListView between them. You can set header and footer views on the ListView to add the scrollable header and footer content. For simplicity of example here’s the LinearLayout way:

     <LinearLayout android:orientation="vertical" 
                   android:layout_height="match_parent"
                   android:layout_width="match_parent">
          <!--static header content... can be any kind of view-->
          <TextView 
                   android:layout_width="match_parent"
                   android:layout_weight="0"
                   android:layout_height="wrap_content"/>
          <ListView 
                   android:id="@+id/list"
                   android:layout_width="match_parent"
                   android:layout_height="0dp"
                   android:layout_weight="1"/>
    
          <!--static footer content... can be any kind of view-->
          <TextView 
                   android:layout_width="match_parent"
                   android:layout_weight="0"
                   android:layout_height="wrap_content"/>
     </LinearLayout>
    

    And in code, you can say:

    ListView theList = (ListView)findViewById(R.id.list);
    
    // example of creating header and footer views from inflation or by instantiation in code
    View myHeaderView = getLayoutInflater().inflate(R.layout.myHeaderLayout,theList,false);
    View myFooterView = new TextView(this, some layout params);
    
    theList.addHeaderView(myHeaderView); 
    theList.addFooterView(myFooterView); 
    

    ListView.addHeaderView and ListView.addFooterView should enable you to add other static views (whose content could be updated dynamically) to the top or bottom of a ListView:

    public void addHeaderView (View v)
    

    Since: API Level 1 Add a fixed view to appear at the top of the list.
    If addHeaderView is called more than once, the views will appear in
    the order they were added. Views added using this call can take focus
    if they want.

    NOTE: Call this before calling setAdapter. This is so ListView can
    wrap the supplied cursor with one that will also account for header
    and footer views.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I'm trying to select an H1 element which is the second-child in its group
I have an array which has BIG numbers and small numbers in it. I

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.