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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:51:34+00:00 2026-06-08T11:51:34+00:00

my app needs to display data in a list, I walked through some tutorials

  • 0

my app needs to display data in a list, I walked through some tutorials and figured out to use a header.xml and row.xml. It works fine but now I would like to add more stuff on my header.xml and I found out that the entire header.xml is scrolling with the row.xml as well, which I dont really want.
Any solution that doesn’t require me to rewrite and change my code style completely?

Activity:

public class HistoryActivity extends ListActivity
{

private static final String TAG = "HistoryActivity";
ListView lv;
SimpleAdapter sd;

RecordDAO dao = new RecordDAO(HistoryActivity.this);

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    lv = getListView();
    lv.addHeaderView(getLayoutInflater().inflate(
            R.layout.header, null, false));


}

@Override
protected void onResume()
{
    super.onResume();
    ArrayList<Record> Records = new ArrayList<Record>();
    Records = (ArrayList<Record>) dao.findAll();


    ArrayList<HashMap<String, String>> aList = new ArrayList<HashMap<String, String>>();
    HashMap<String, String> map;

    for (int x = Records.size()-1; x >=0; x--)
    {
        map = new HashMap<String, String>();
        map.put(....// all my data 

        aList.add(map);
    }

    sd = new SimpleAdapter(this, aList, R.layout.row,
            new String[]
            { "date", "name", "time",
                    "rating" }, new int[]              
            { R.id.date, R.id.name, R.id.time,
                     R.id.rating});


    lv.setAdapter(sd);

    lv.setOnItemClickListener(new OnItemClickListener()
    {

        public void onItemClick(AdapterView<?> arg0, View view, int arg2,
                long arg3)
        {
            TextView tx = (TextView) view.findViewById(R.id.date);
            String s = tx.getText().toString();
            Intent intent = new Intent(HistoryActivity.this, EditRecordActivity.class);
            intent.putExtra("date", s);
            startActivity(intent);

        }
    });

}

private void insertNewRecord()
{
    dao.add(newRecord);
}

}

header.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:orientation="vertical" >


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:orientation="horizontal"
        android:paddingBottom="6dip"
        android:paddingTop="4dip" >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Date"
            android:textColor="#FFFFFF"
            android:textSize="16dp" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="name"
            android:textColor="#FFFFFF"
            android:textSize="16dp" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Time"
            android:textColor="#FFFFFF"
            android:textSize="16dp" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Rating"
            android:textColor="#FFFFFF"
            android:textSize="16dp" />
    </LinearLayout>

</LinearLayout>

row.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:paddingBottom="6dip"
    android:paddingTop="4dip" >

    <TextView
        android:id="@+id/date"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/name"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_weight="1"
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/time"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/Rating"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textColor="#FFFFFF" />

</LinearLayout>
  • 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-08T11:51:35+00:00Added an answer on June 8, 2026 at 11:51 am

    Don’t use ListActivity. I think it is a bad practice. Use a regular Activity. Just insert a ListView with an id “@android:id/list” into header.xml.

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:orientation="horizontal"
        android:paddingBottom="6dip"
        android:paddingTop="4dip" >
    
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Date"
            android:textColor="#FFFFFF"
            android:textSize="16dp" />
    
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="name"
            android:textColor="#FFFFFF"
            android:textSize="16dp" />
    
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Time"
            android:textColor="#FFFFFF"
            android:textSize="16dp" />
    
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Rating"
            android:textColor="#FFFFFF"
            android:textSize="16dp" />
    </LinearLayout>
    
    <ListView
        android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </ListView>
    

    And you can get the list reference by doing:
    ListView lv = (ListView)findViewById(R.id.list);

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

Sidebar

Related Questions

My app needs to display a graphical representation of a value ranging from -1
My app needs to install some files that can be edited by the application
I'm working on an Android app that needs to be able to display information
I've got a .NET MVC app where I need to display a list of
I want to create an informative app that will display a list of content.
My App has a List-view to display values from an SQLite DB. There is
We are making an app whose primary purpose is to display data, but we
One of the activities in my app is a listview which needs to display
Have a rails app that is supposed to display a list of products/managers. After
On page 1 of a mobile app I need to display categories from a

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.