I have a simple Person class:
public class Employee {
public String Name;
public int ID;
public TVShow(String employeeName, int employeeID)
{
Name = employeeName;
ID = employeeID;
}
}
I am populating a List (in this case named xmlHandler.employees) with classes containing the name and id of employees.
I then want to bind this list to a ListView:
ArrayAdapter<TVShow> itemList = new ArrayAdapter<TVShow>(this, R.layout.listcontent, xmlHandler.emplyoyees);
ListView showList = (ListView)findViewById(android.R.id.list);
showList.setAdapter(itemList);
All is well apart from I don't know how to set which field of the Person class I want to display in the ListView. If possible I would like to set the display text of the ListView item to Person.Name and the id to Person.ID.
Basically my goal of all this is to have a List of employees, when a name is clicked then a lookup is done on the employee id and passed to another activity. Currently I am stuck on just displaying the name and having the id in there somewhere aswell.