I've a listview which already contain a list of data.
What I'm trying to achieve is when I click one of the ListItem, I want to add another bunch of dataset just below the clicked item.
protected void onListItemClick(ListView l, View v, int position, long id) {
if (position == 0) {
/*
*
* want to add another bunch of data just below postion 0!!!
*
*/
}
}
You can insert the data in the adapter that you use with list view and then call the notifyDataSetChanged() on the adapter to update the list view. You should use an ArrayAdapter (or its subclass) to be able to dynamically add objects to the list view.
((ArrayAdapter)listView.getAdapter()).insert(object, index);
((ArrayAdapter)listView.getAdapter()).notifyDataSetChanged();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With