I am developing a messaging app; all is going well and I am doing some research on how to add data to the ListView once the user receives a new message. From what I have gathered so far, the notifyDataSetChanged()
function does this. The tutorial I have uses the function below to update data in the ListView.
private void addItemsToList() {
int randomVal = MIN + (int) (Math.random() * ((MAX - MIN) + 1));
mItems.add(String.valueOf(randomVal));
mListAdapter.notifyDataSetChanged();
}
As you can see, this will update a single value randomVal
to the ArrayList. In a messaging scenario, the data to be updated includes the message, sender username and time of sending the message.
My question is, will the above function add more than one item to the ListView Row and if not, what modifications should be made to enable it add more than one value to the ListView?