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.
You should just simply add the newly arrived items to your list of data (the already listed 5 items), and call
notifyDatasetChanged()on yourListAdapterimplementation.Update
Here I share a sample activity which contains a list and a
TextViewat the bottom (inflated fromstepping_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.xmlFor 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:is a simple
TextView, and the renderer for the last item (of the initial list)res/layout/row_with_button.xml:Finally the
Activityclass that connects these layouts:SteppingListActivity.java:I hope you got the idea 🙂