I have a basic object called Employee. You can retrieve an Employee’s name and id using .getName() and .getId().
I want to use Jeff Sharkey’s SeparatedListAdapter to build a sectioned list. For the list items though, I need to use my custom Employee objects for the items instead of just lists of Strings.
In the included examples for the SeparatedListAdapter, he uses an ArrayAdapter<String> and a SimpleAdapter() for populating the list.
Is there any way to use a custom object/class, like my Employee class? The reason I’m needing to do this, is that when I click on an item in the list, I want to retrieve the actual Employee object that I used for that item and then retrieve the ID of the employee so I can display information pertaining to that Employee.
I’m a little bit confused on how to use Adapters properly. Should I make my own adapter or something?
You’ll need to implement your custom adapter. Ex:
and when use it on SeparatedListAdapter:
Edit:
Overrride getView Method in your CustomAdapter to create views with Employee info. Like this: