I have a ListView populated with hardcoded data from an ArrayList. The list contains Person objects.
I have successfully got them to display in the list and assigned a listener to each item. What I am trying to do is add the selected item to an ArrayList called employees.
protected void onListItemClick(listView l, View v, int position, long id){
Person p = l.getItemAtPosition(position);
employees.add(p);
}
I am aware the above code will not work as the getItemAtPosition returns a long value. However is there a way I can work with this value to create a person object to hold the item clicked by the user?
So basically I have a ListView populated by data in ArrayList people.
ArrayList<Person> people;
I then want to addthe item clicked by the user into an ArrayList employee.
ArrayList<Person> employee;