I have an object:
private ArrayList<HashMap<String, String>> customerDataList;
Which I populate with data retrieved from a web service call. The below is inside a loop iterating over the retrieved json data:
HashMap<String, String> customer = new HashMap<>();
//snip
customer.put("CustomerName", customerName);
//snip
customerDataList.add(customer);
//rinse and repeat
Then I display this in a list view in my activity with:
ListAdapter adapter = new SimpleAdapter(Activity.this, customerDataList,
R.layout.list_item, new String[] {"CustomerName"}, new int[] { R.id.customerName });
setListAdapter(adapter);
However I am wondering if there is a way I can use a List instead.
I created my customer class, created a List of it like so:
private List<Customer> customerList;
However when it comes to setting the ListAdapter I am unsure of what to put. I replaced customerDataList with customerList but I receive errors.
Edit: The error is
SimpleAdapter() in SimpleAdapter cannot be applied to:
Expected data: java.util.Map<java.lang.String.?>>
Actual arguments: customerList <Customer>
Edit: my class structure
private class Customer
{
private int customerID;
private String customerName;
private String customerLocation;
private String runningTime;
private double distance;
}