ArrayAdapter has method add(T object)
which add an object at the end of a list. Is there a way to add object at the beginning of the list?
To add rows to a ListView you need to add it to your layout and implement an IListAdapter with methods that the ListView calls to populate itself. Android includes built-in ListActivity and ArrayAdapter classes that you can use without defining any custom layout XML or code.
notifyDataSetChanged. Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.
You can use the .insert(T object, int index)
method for this, using 0
as an index:
yourAdapter.insert(object, 0);
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