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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:16:00+00:00 2026-05-22T01:16:00+00:00

i have a list in android. and it has 30 records currently. but on

  • 0

i have a list in android. and it has 30 records currently.
but on my activity i am only showing 5 records… after 5 records it shows me a button
“Display All Data”

when i click on that button, then it should display all 30 records and update the activity List. Please tell me how can i update. like we do in AJAX in web technology. i hope u guys understand what i am trying to say?

Refresh the Activity without refreshing the whole activity. Please Reply Friends.

waiting for positive response.

  • 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-22T01:16:01+00:00Added an answer on May 22, 2026 at 1:16 am

    You should just simply add the newly arrived items to your list of data (the already listed 5 items), and call notifyDatasetChanged() on your ListAdapter implementation.

    Update
    Here I share a sample activity which contains a list and a TextView at the bottom (inflated from stepping_list.xml), where the list initially contains 5 items, and at the bottom a button. When pressing the button, other 25 values get loaded into the list, and the button disappears.

    For this we need the main layout, res/layout/stepping_list.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="wrap_content">
        <TextView android:id="@+id/footer"
            android:layout_width="fill_parent" android:layout_height="60dp"
            android:background="@drawable/box"
            android:text="Lazy loading list in steps" android:textStyle="bold"
            android:gravity="center_vertical|center_horizontal"
            android:layout_alignParentBottom="true" />
        <ListView android:id="@+id/list"
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:layout_alignParentTop="true" android:layout_above="@id/footer" />
    </RelativeLayout>
    

    For the Load more data button to always appear after the last item of the initial list (even if need to scroll to it), I put it into the list’s item renderer layout. This way the list will have two item renderers.

    The common renderer res/layout/row.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/textView" android:layout_alignParentRight="true"
        android:layout_width="fill_parent" android:layout_height="60dp"
        android:gravity="center_vertical|right" android:paddingRight="10dp"
        android:textSize="35dp"
        android:textColor="#2B78E4" />
    

    is a simple TextView, and the renderer for the last item (of the initial list)
    res/layout/row_with_button.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:orientation="vertical">
        <TextView android:id="@+id/textView"
            android:layout_alignParentRight="true"
            android:layout_width="fill_parent" android:layout_height="60dp"
            android:gravity="center_vertical|right" android:paddingRight="10dp"
            android:layout_weight="1" android:textColor="#2B78E4"
            android:textSize="35dp" />
        <Button android:id="@+id/loadbtn"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="1" android:text="Load more data"
            android:onClick="loadMoreData" />
    </LinearLayout>
    

    Finally the Activity class that connects these layouts:
    SteppingListActivity.java:

    public class SteppingListActivity extends Activity
    {
        private MyAdapter adapter;
        private ArrayList<Integer> values;
    
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.stepping_list);
    
            //initialize the list of data which will populate the list
            //TODO: You need to retrieve this data from the server, but I use
            //      here simple int values.
            values = new ArrayList<Integer>();
            for (int i = 0; i < 5; i++)
            {
                values.add((i % 2 == 0) ? i * 3 : i + 3);
            }
    
            //initialize the adapter, and attach it to the ListView:
            adapter = new MyAdapter();
            final ListView listView = (ListView) findViewById(R.id.list);
            listView.setAdapter(adapter);
        }
    
        /**
         * The onClick function of the last itemrenderer's button
         * @param button the button clicked.
         */
        public void loadMoreData(View button)
        {
            //Just put some more data into the values ArrayList:
            //TODO: You need to retrieve these data from the server, as well!
            for (int i = 5; i < 30; i++)
            {
                values.add((i % 2 == 0) ? i * 3 : i + 3);
            }
            //notify the ListAdapter about the changes:
            adapter.notifyDataSetChanged();
        }
    
        /**
         * The custom ListAdapter class used to populate the ListView
         */
        private class MyAdapter extends BaseAdapter
        {
            private LayoutInflater inflater;
    
            public MyAdapter()
            {
                inflater = LayoutInflater.from(SteppingListActivity.this);
            }
    
            @Override
            public View getView(int position, View convertView, ViewGroup parent)
            {
                //check if the current item to show is the last item of the 
                //  initial list, and if so, inflate the proper renderer for it:
                if ((position == 4) && (values.size() == 5))
                    convertView = inflater.inflate(
                            R.layout.row_with_button, parent, false);
                else if ((convertView == null) || 
                        (convertView.findViewById(R.id.loadbtn) != null))
                    convertView = inflater.inflate(R.layout.row, parent, false);
                //set the value of the TextView 
                ((TextView) convertView.findViewById(
                        R.id.textView)).setText(values.get(position)+ ".50 €");
    
                return convertView;
            }
            @Override
            public int getCount()
            {
                return values.size();
            }
            @Override
            public Object getItem(int position)
            {
                return values.get(position);
            }
            @Override
            public long getItemId(int position)
            {
                return position;
            }
        }
    }
    

    I hope you got the idea 🙂

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

Sidebar

Related Questions

My Android app has a ContactsList activity in which I simply display a list
It seems that android has enforced that a listview must have the name android:id=@android:id/list,
I'm developing an Android application. On one activity I have a List with list
I have an Android activity with a list. Each item can be clicked and
I have an Android activity which has a header, some title text, and then
On my screen I have a list view and a button. my list has
I have a listview : <ListView android:clickable=true android:id=@android:id/list android:layout_width=match_parent android:layout_height=wrap_content > </ListView> the elements
I have created an ExpandableListView with the following code: <ExpandableListView android:id=@+id/android:list android:layout_width=wrap_content android:layout_height=0dp android:layout_marginTop=5dp
In my XML, I have the following <ListView android:id=@android:id/list android:layout_width=match_parent android:layout_height=fill_parent > </ListView> How
i have recently developed a list program in android in which there is an

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.