I created a simple class MapExtension to accomodate passing of 4 values to a listview adapter and used LinkedHashmap to add the ArrayList of MapExtension.
public class MapExtension {
private String studname;
private String studnumber;
private String schedule;
public MapExtension(String studname, String studnumber, String schedule) {
this.studname = studname;
this.studnumber= studnumber;
this.schedule= schedule;
}
public String getStudname () {
return studname;
}
public String getStudnumber() {
return studnumber;
}
public String getSchedule() {
return schedule;
}
}
Whenever I try to extract the ArrayList<MapExtension> from LinkedHashMap returning Collections, I get these errors from different trials(in comments):
ListViewAdapter(Context context, LinkedHashMap<Integer, ArrayList<MapExtension>> mValues) {
super(context, R.layout.listview_layout, mValues.keySet().toArray());
this.context = context;
//java.lang.ClassCastException: java.util.HashMap$Values
//cannot be cast to java.util.ArrayList
ArrayList mValues = (ArrayList) mValues.values();
// says incompatible as it will become ArrayList<ArrayList<MapExtension>>
ArrayList<MapExtension> mValues = new ArrayList<>(mValues.values());
}
How can I successfully retrieve it and place in its compatible type?
Thanks in advance.