The problem is that the autocomplete view will filter the displayed content, making it not matching your initial array, meaning you cannot rely on the index given in onItemClick to search the trainee
array.
To limit the amount of change in your code, here is what you can do:
Use a SimpleAdapter like so:
SimpleAdapter adapter = new SimpleAdapter(this, trainee,
R.layout.search_autocomplete, new String[] {"display"},
new int[] {R.id.text});
// R.id.text is to be replaced by the id of your TextView in the search_autocomplete layout
Then, in onItemClick, retrieve the Map that represent the trainee like so:
Map<String, String> selectedTrainee = ((Map<String, String>) arg0.getItemAtPosition(arg2));
You can then manipulate the object any way you need (last name is selectedTrainee.get("last_name")
)